Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match against multiple header values #117

Open
sagebind opened this issue May 2, 2020 · 0 comments
Open

Match against multiple header values #117

sagebind opened this issue May 2, 2020 · 0 comments

Comments

@sagebind
Copy link

sagebind commented May 2, 2020

For my HTTP client I now have the need to assert that repeated headers are being sent or not with the correct values and number of times. For example, I kind of expected the following to work:

let m = mock("GET", "/")
    .match_header("x-header", "some-value1")
    .match_header("x-header", "some-value2")
    .create();

I want to assert that x-header is present twice in the request, one with the value some-value1 and another with the value some-value2. After looking at the source, I now understand that this will never match anything because instead two matchers are created, both expecting all occurrences of x-header to be equal to the respective values. (Incidentally, seems the error diff is a bit bugged in this scenario and points to the wrong header, but I need to poke around that further.)

I don't currently see a way of asserting what I want to assert, though I do see that internally matchers are given all header values as a slice. I guess this is a feature request then for some sort of matcher that contains a list of matchers, but unlike Matcher::AllOf, requires that each matcher in the list matches a header value uniquely exactly once.

I'd be willing to implement this if this sounds like something you'd be willing to accept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant