< 返回版块

mook 发表于 2023-09-06 19:13

Tags:rust,日报

Grillon - API 测试框架

  • 优雅、直观和富有表现力的 API
  • 内置测试功能
  • 支持扩展

用法:

use grillon::{dsl::*, dsl::http::*, json, Grillon, StatusCode, Result};
use grillon::header::{HeaderValue, CONTENT_LENGTH, CONTENT_TYPE};

#[tokio::test]
async fn end_to_end_test() -> Result<()> {
    Grillon::new("https://jsonplaceholder.typicode.com")?
        .post("posts")
        .payload(json!({
            "title": "foo",
            "body": "bar",
            "userId": 1
        }))
        .assert()
        .await
        .status(is_success())
        .status(is(201))
        .response_time(is_less_than(700))
        .json_body(is(json!({
            "id": 101,
        })))
        .json_body(schema(json!({
            "properties": {
                "id": { "type": "number" }
            }
        })))
        .json_path("$.id", is(json!(101)))
        .headers(contains(vec![
            (
                CONTENT_TYPE,
                HeaderValue::from_static("application/json; charset=utf-8"),
            ),
            (CONTENT_LENGTH, HeaderValue::from_static("15")),
        ]))
        .assert_fn(|assert| {
            assert!(!assert.headers.is_empty());
            assert!(assert.status == StatusCode::CREATED);
            assert!(assert.json.is_some());

            println!("Json response : {:#?}", assert.json);
        });

    Ok(())
}

ReadMore:https://github.com/owlduty/grillon

qcd - 快速切换目录

qcd是一个Linux工具,有助于提高命令行的效率。

切换目录
qcd ENTRY [-n]  Chdir to path with idx or alias ENTRY (w/o -n: adds work dir to stack)
qcd -o          (pop)  Chdir to top of stack, remove that entry from stack
添加或删除入口
qcd -a PATH [-i IDX] [-s ALIAS]   Add PATH to database
qcd -p [-i IDX] [-s ALIAS]        Add current working directory to database
qcd -r ENTRY                      Remove row with idx or alias ENTRY
qcd -u                            (push) Add current working directory to (top of) stack

ReadMore:https://github.com/ClaasBontus/qcd_rs


From 日报小组 mook 社区学习交流平台订阅:

评论区

写评论

还没有评论

1 共 0 条评论, 1 页