alexliesenfeld / httpmock

HTTP mocking library for Rust
https://httpmock.rs
MIT License
488 stars 45 forks source link

Add support for expecting lack of query parameter #93

Closed RichoDemus closed 2 months ago

RichoDemus commented 1 year ago

it was hard writing a good title,

basically what I want to do is create a mock that only triggers if a specific query parameter is missing:

    mock_server.mock(|when, then| {
        when.method(GET).path("/api")
            .query_param("param", "that-I-want")
            .query_param_i_dont_want("bad-param",no")
        ;
        then.status(200).json_body(json!({
           "response": "So good that you didn't add the bad param!"
        }));

so in this case, a call to /api?param=that-I-want will return a 200 with the message a call to /api?param=that-I-want&bad-param=no will not return a 200

alexliesenfeld commented 2 months ago

Should be fixed starting with 0.8.0-alpha.1. Let me know if you miss anything.