Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clechasseur/wiremock_logical_matchers
Logical matchers for wiremock
https://github.com/clechasseur/wiremock_logical_matchers
crates-io mock rust rust-lang wiremock
Last synced: 2 months ago
JSON representation
Logical matchers for wiremock
- Host: GitHub
- URL: https://github.com/clechasseur/wiremock_logical_matchers
- Owner: clechasseur
- License: mit
- Created: 2023-06-25T03:14:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-29T12:40:17.000Z (3 months ago)
- Last Synced: 2024-10-29T13:32:00.808Z (3 months ago)
- Topics: crates-io, mock, rust, rust-lang, wiremock
- Language: Rust
- Homepage: https://crates.io/crates/wiremock_logical_matchers
- Size: 190 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# wiremock_logical_matchers
[![CI](https://github.com/clechasseur/wiremock_logical_matchers/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/clechasseur/wiremock_logical_matchers/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/clechasseur/wiremock_logical_matchers/branch/main/graph/badge.svg?token=NIW54Q8UC3)](https://codecov.io/gh/clechasseur/wiremock_logical_matchers) [![Security audit](https://github.com/clechasseur/wiremock_logical_matchers/actions/workflows/audit-check.yml/badge.svg?branch=main)](https://github.com/clechasseur/wiremock_logical_matchers/actions/workflows/audit-check.yml) [![crates.io](https://img.shields.io/crates/v/wiremock_logical_matchers.svg)](https://crates.io/crates/wiremock_logical_matchers) [![downloads](https://img.shields.io/crates/d/wiremock_logical_matchers.svg)](https://crates.io/crates/wiremock_logical_matchers) [![docs.rs](https://img.shields.io/badge/docs-latest-blue.svg)](https://docs.rs/wiremock_logical_matchers) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
Additional [matchers](https://docs.rs/wiremock/latest/wiremock/trait.Match.html) for [wiremock](https://crates.io/crates/wiremock) that implement logical operators (AND, OR, XOR, NOT).
# Installing
Add `wiremock_logical_matchers` to your development dependencies:
```toml
[dev-dependencies]
wiremock = "0.6.0"
wiremock_logical_matchers = "0.6.0"
```or by running:
```bash
cargo add wiremock_logical_matchers --dev
```# Getting started
```rust
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](https://crates.io/crates/wiremock)