httptest icon indicating copy to clipboard operation
httptest copied to clipboard

support matching by query string

Open dzmitry-lahoda opened this issue 3 years ago • 1 comments

/foobar matches /foobar?file_type=zip while /foobar?file_type=zip fails to match /foobar?file_type=zip

dzmitry-lahoda avatar Feb 17 '21 21:02 dzmitry-lahoda

Sorry, I'm not sure I understand what exactly matches or doesn't match here. Would you mind posting a snippet of code that identifies what's expected and isn't working? Thanks.

ggriffiniii avatar Feb 17 '21 22:02 ggriffiniii

@dzmitry-lahoda there is a separate matcher for matching the query I fell into the same hole because the README doesn't show you that there is a separate matcher for this, you can find it in the source code though

Your example would look something like this

server.expect(
    Expectation::matching(all_of![
        request::method("GET"),
        request::path("/foobar"),
        request::query("file_type=zip"),
    ])
    .respond_with(json_encoded(json!({"result": "success"}))),
);

arkus7 avatar Dec 12 '22 08:12 arkus7