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

feat: HaveHTTPStatus multiple expected values #465

Merged
merged 3 commits into from Aug 19, 2021

Conversation

blgm
Copy link
Collaborator

@blgm blgm commented Aug 15, 2021

Note, this builds on #461, so that should be merged first.

Sometimes more than one HTTP status is acceptable. For example a server
may (correctly) return HTTP 204 for an empty response, or it might
return HTTP 200 for an empty response - and we might want to accept
either.

We can now write:

Expect(resp).To(HaveHTTPStatus(http.StatusOK, http.StatusNoContent))

And it will match either. This is simpler than using Or() or
SatisfyAny().

Previously when the HaveHTTPStatus() matcher failed, the whole HTTP
response object was printed out, and any message was rendered in
bytes rather than as a string.

This introduces a formatter for HTTP responses, so that the key data is
presented in a helpful format.
@blgm blgm force-pushed the have-http-status-multiple-value branch from a2583e0 to 6481fcb Compare August 17, 2021 11:08
Sometimes more than one HTTP status is acceptable. For example a server
may (correctly) return HTTP 204 for an empty response, or it might
return HTTP 200 for an empty response - and we might want to accept
either.

We can now write:
```go
Expect(resp).To(HaveHTTPStatus(http.StatusOK, http.StatusNoContent))
```
And it will match either. This is simpler than using Or() or
SatisfyAny().
@blgm blgm force-pushed the have-http-status-multiple-value branch from 6481fcb to c573b36 Compare August 17, 2021 11:20
blgm added a commit that referenced this pull request Aug 17, 2021
@onsi onsi merged commit aa69f1b into master Aug 19, 2021
onsi pushed a commit that referenced this pull request Aug 19, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants