2 releases (1 stable)

1.0.0 Aug 9, 2024
0.1.0 Jan 4, 2022

#211 in Testing

Download history 157/week @ 2024-07-19 112/week @ 2024-07-26 163/week @ 2024-08-02 318/week @ 2024-08-09 110/week @ 2024-08-16 233/week @ 2024-08-23 98/week @ 2024-08-30 37/week @ 2024-09-06 68/week @ 2024-09-13 81/week @ 2024-09-20 186/week @ 2024-09-27 56/week @ 2024-10-04 87/week @ 2024-10-11 24/week @ 2024-10-18 43/week @ 2024-10-25 38/week @ 2024-11-01

200 downloads per month
Used in fhttp-core

MIT license

31KB
802 lines

wiremock-multipart

This project provides matchers dealing with multipart requests for the awesome wiremock testing framework.

How to install

Add wiremock-multipart to your development dependencies:

[dev-dependencies]
# ...
wiremock-multipart = "0.1"

If you are using cargo-edit, run

cargo add wiremock-multipart --dev

Getting started

use wiremock::{MockServer, Mock, ResponseTemplate};
use wiremock::matchers::method;
use wiremock_multipart::prelude::*;

#[async_std::main]
async fn main() {
    // Start a background HTTP server on a random local port
    let mock_server = MockServer::start().await;

    // Arrange the behaviour of the MockServer adding a Mock
    Mock::given(method("POST"))
        .and(NumberOfParts(2))
        .respond_with(ResponseTemplate::new(200))
        // Mounting the mock on the mock server - it's now effective!
        .mount(&mock_server)
        .await;

    // if we now send a multipart/form-data request with two parts to it, the request
    // will match and return 200.
}

Dependencies

~13–23MB
~336K SLoC