7 releases

0.6.0 Feb 21, 2024
0.5.1 Jan 14, 2024
0.5.0 Dec 31, 2023
0.1.3 Oct 13, 2023
0.1.1 Jul 4, 2023

#451 in Asynchronous

Download history 2040/week @ 2024-07-22 263/week @ 2024-07-29 420/week @ 2024-08-05 127/week @ 2024-08-12 363/week @ 2024-08-19 274/week @ 2024-08-26 310/week @ 2024-09-02 364/week @ 2024-09-09 349/week @ 2024-09-16 289/week @ 2024-09-23 1125/week @ 2024-09-30 20/week @ 2024-10-07 448/week @ 2024-10-14 262/week @ 2024-10-21 671/week @ 2024-10-28 394/week @ 2024-11-04

1,775 downloads per month
Used in mini_exercism

MIT license

15KB
121 lines

wiremock_logical_matchers

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

Additional matchers for wiremock that implement logical operators (AND, OR, XOR, NOT).

Installing

Add wiremock_logical_matchers to your development dependencies:

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

or by running:

cargo add wiremock_logical_matchers --dev

Getting started

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;

    // ...
}

See also

wiremock on crates.io

Dependencies

~12–23MB
~317K SLoC