httpmock icon indicating copy to clipboard operation
httpmock copied to clipboard

Add support for expecting lack of query parameter

Open RichoDemus opened this issue 2 years ago • 0 comments

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

RichoDemus avatar Oct 19 '23 22:10 RichoDemus