alexliesenfeld / httpmock

HTTP mocking library for Rust.
MIT License
435 stars 40 forks source link

Add support for expecting lack of query parameter #93

Open RichoDemus opened 8 months ago

RichoDemus commented 8 months 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