4 releases
0.1.3 | Oct 13, 2023 |
---|---|
0.1.2 | Aug 21, 2023 |
0.1.1 | Jul 4, 2023 |
0.1.0 | Jul 1, 2023 |
#318 in Asynchronous
503 downloads per month
Used in mini_exercism
16KB
139 lines
wiremock_logical_matchers
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"
wiremock_logical_matchers = "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};
#[async_std::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-voldemort")
)
).respond_with(ResponseTemplate::new(200))
.mount(&mock_server)
.await;
// ...
}
See also
Dependencies
~15MB
~292K SLoC