fix faulty tests for distribution-client#46555
Merged
thaJeztah merged 2 commits intomoby:masterfrom Sep 27, 2023
Merged
Conversation
This utility was setting the content-type header after WriteHeader was called, and the header was not sent because of that. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The test was depending on the client constructing an error based on the http-status code, and the client not reading the response body if the response was not a JSON response. This fix; - adds the correct content-type headers in the response - includes error-messages in the response - adds additional tests to cover both the plain (non-JSON) and JSON error responses, as well as an empty response. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 task
rumpl
reviewed
Sep 27, 2023
| { | ||
| name: "unauthorized JSON no body", | ||
| handler: func(callCount int, w http.ResponseWriter) { | ||
| w.Header().Set("Content-Type", "application/json") |
Member
There was a problem hiding this comment.
Do some registries really respond with application/json and an empty body? Because empty is not valid JSON, it needs to be [] or {}
Member
Author
There was a problem hiding this comment.
I don't think they would, or at least I would expect any server to have a body (which could be HTML), but the existing test seemed to handle it on the client side (I was actually surprised by that), so wanted to keep the test-case for that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
integration-cli: fix getTestTokenService not sending header
This utility was setting the content-type header after WriteHeader was
called, and the header was not sent because of that.
distribution: TestPullSchema2Config fix test response
The test was depending on the client constructing an error based on the
http-status code, and the client not reading the response body if the
response was not a JSON response.
This fix;
error responses, as well as an empty response.
- A picture of a cute animal (not mandatory but encouraged)