chore: revamp validate response tests #232
Open
+1,771
−706
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.
WHAT :
As mentioned some time ago in this PR #131 using an httptest.Server gives allows us to tests against real world scenarios.
I've mentioned back then that If you'd like I'd be happy to make another PR in order to adjust the tests accordingly, and, even though it took me some time to get back to it due to personal reason here I am as promised.
The following changes introduce a test bed in order to simplify the tests setup and avoid redundant operations and each tests have been adjusted to make use of this new test bed.
The validate response has been updated to actually reflect the real world scenario where http body is equal to http.NoBody as having a nil body is actually something that can't happen.
If you are satisfy with this PR I'll adjust the other tests to reflect this pattern
NOTE :
Following some CI failures regarding linting I took the liberty to add a pre-commit check that'll run golangci-lint locally using go tool command that way we ensure we don't waste any CI resource (at least for the ones who install the hooks)