Skip to content

Commit

Permalink
Uses strings.Contains to validate response in handlers_test
Browse files Browse the repository at this point in the history
  • Loading branch information
saltiyazan committed May 6, 2024
1 parent 05ac361 commit fe5b1ad
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions internal/api/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,8 @@ func TestGoCertRouter(t *testing.T) {
if err != nil {
t.Fatal(err)
}
switch path := tC.path; path {
case "/metrics":
if res.StatusCode != tC.status || !strings.Contains(string(resBody), tC.response) {
t.Errorf("expected response did not match.\nExpected vs Received status code: %d vs %d\nExpected vs Received body: \n%s\nvs\n%s\n", tC.status, res.StatusCode, tC.response, string(resBody))
}
default:
if res.StatusCode != tC.status || string(resBody) != tC.response {
t.Errorf("expected response did not match.\nExpected vs Received status code: %d vs %d\nExpected vs Received body: \n%s\nvs\n%s\n", tC.status, res.StatusCode, tC.response, string(resBody))
}
if res.StatusCode != tC.status || !strings.Contains(string(resBody), tC.response) {
t.Errorf("expected response did not match.\nExpected vs Received status code: %d vs %d\nExpected vs Received body: \n%s\nvs\n%s\n", tC.status, res.StatusCode, tC.response, string(resBody))
}
})
}
Expand Down

0 comments on commit fe5b1ad

Please sign in to comment.