#mocking #wiremock #http #testing

wiremock_logical_matchers

用于 wiremock 的逻辑匹配器

7 个版本

0.6.0 2024年2月21日
0.5.1 2024年1月14日
0.5.0 2023年12月31日
0.1.3 2023年10月13日
0.1.1 2023年7月4日

#253 in 异步

Download history 557/week @ 2024-04-07 601/week @ 2024-04-14 354/week @ 2024-04-21 296/week @ 2024-04-28 597/week @ 2024-05-05 499/week @ 2024-05-12 400/week @ 2024-05-19 181/week @ 2024-05-26 292/week @ 2024-06-02 477/week @ 2024-06-09 236/week @ 2024-06-16 289/week @ 2024-06-23 419/week @ 2024-06-30 279/week @ 2024-07-07 290/week @ 2024-07-14 2000/week @ 2024-07-21

2,988 每月下载量
用于 mini_exercism

MIT 许可证

15KB
121

wiremock_logical_matchers

CI codecov Security audit crates.io downloads docs.rs Contributor Covenant

wiremock 实现逻辑运算符(AND、OR、XOR、NOT)的额外 匹配器

安装

wiremock_logical_matchers 添加到您的开发依赖项

[dev-dependencies]
wiremock = "0.6.0"
wiremock_logical_matchers = "0.6.0"

或运行

cargo add wiremock_logical_matchers --dev

入门

use wiremock::{Mock, MockServer, ResponseTemplate};
use wiremock::matchers::{header, header_exists, path, query_param};
use wiremock_logical_matchers::{and, not, or, xor};

#[tokio::test]
async fn test_getting_started() {
    let mock_server = MockServer::start().await;

    Mock::given(path("/test"))
        .and(
            and(
                header_exists("x-for-testing-purposes"),
                query_param("page", "1")
            )
        ).and(
            or(
                header("authorization", "Bearer some_token"),
                query_param("override-security", "1")
            )
        ).and(
            xor(
                header("x-license", "MIT"),
                header("x-license-file", "LICENSE")
            )
        ).and(
            not(
                header_exists("x-necronomicon")
            )
        ).respond_with(ResponseTemplate::new(200))
        .mount(&mock_server)
        .await;

    // ...
}

另请参阅

crates.io 上的 wiremock

依赖项

~11–22MB
~334K SLoC