-
Notifications
You must be signed in to change notification settings - Fork 58
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
[GH-358] Bug Fix sending "null" body in unnecessary requests #387
Conversation
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), testCase.expectedError.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance we can make the expectedError
a string and then use assert.EqualError
instead? This would reduce the assertions to just 1 line.
if testCase.expectedError != nil { | ||
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), testCase.expectedError.Error()) | ||
assert.Nil(t, request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could return immediately after this assert and then remove the else
block.
}{ | ||
{ | ||
name: "Valid GET request", | ||
method: "GET", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance we could use the constants from the http
package for the methods? http.MethodGet
if testCase.method == "GET" || testCase.method == "DELETE" { | ||
requestBody, _ := io.ReadAll(request.Body) | ||
assert.Empty(t, string(requestBody)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove these conditional checks inside the assertions if we have an expectedBody
on the testCases
as well and then simply do an assert.Equal
.
transfer_encoding: [] | ||
trailer: {} | ||
host: go-auth0-dev.eu.auth0.com | ||
remote_addr: "" | ||
request_uri: "" | ||
body: | | ||
null | ||
body: "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
🔧 Changes
📚 References
🔬 Testing
📝 Checklist