Skip to content

Commit

Permalink
Issue #28: improve asserts in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
idrissneumann committed Dec 11, 2023
1 parent 81ad8c9 commit c037165
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/quickwit/error_handling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ func TestErrorAvgMissingField(t *testing.T) {
LogMessageField: "line",
LogLevelField: "lvl",
}
_, err := queryDataTestWithResponseCode(query, 400, response, configuredFields)
// FIXME: add asserts to also test the result is containing an error with the 400 status code

result, err := queryDataTestWithResponseCode(query, 400, response, configuredFields)
require.Nil(t, err)
require.Contains(t, result.response.Responses["A"].Error.Error(), "\"status\":400")
}

func TestErrorAvgMissingFieldNoDetailedErrors(t *testing.T) {
Expand Down Expand Up @@ -76,9 +77,10 @@ func TestErrorAvgMissingFieldNoDetailedErrors(t *testing.T) {
LogMessageField: "line",
LogLevelField: "lvl",
}
_, err := queryDataTestWithResponseCode(query, 400, response, configuredFields)
// FIXME: add asserts to also test the result is containing an error with the 400 status code

result, err := queryDataTestWithResponseCode(query, 400, response, configuredFields)
require.Nil(t, err)
require.Contains(t, result.response.Responses["A"].Error.Error(), "\"status\":400")
}

func TestErrorTooManyDateHistogramBuckets(t *testing.T) {
Expand Down Expand Up @@ -160,7 +162,8 @@ func TestNonElasticError(t *testing.T) {
LogMessageField: "line",
LogLevelField: "lvl",
}
_, err := queryDataTestWithResponseCode(query, 403, response, configuredFields)
// FIXME: add asserts to also test the result is containing an error with the 403 status code

result, err := queryDataTestWithResponseCode(query, 403, response, configuredFields)
require.Nil(t, err)
require.Contains(t, result.response.Responses["A"].Error.Error(), "\"status\":403")
}

0 comments on commit c037165

Please sign in to comment.