Skip to content

Commit 6ef8e3f

Browse files
committed
Issue #28: improve asserts in unit tests
1 parent aeac91c commit 6ef8e3f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pkg/quickwit/error_handling_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ func TestErrorAvgMissingField(t *testing.T) {
4444
LogMessageField: "line",
4545
LogLevelField: "lvl",
4646
}
47-
_, err := queryDataTestWithResponseCode(query, 400, response, configuredFields)
48-
// FIXME: add asserts to also test the result is containing an error with the 400 status code
47+
48+
result, err := queryDataTestWithResponseCode(query, 400, response, configuredFields)
4949
require.Nil(t, err)
50+
require.Contains(t, result.response.Responses["A"].Error.Error(), "\"status\":400")
5051
}
5152

5253
func TestErrorAvgMissingFieldNoDetailedErrors(t *testing.T) {
@@ -76,9 +77,10 @@ func TestErrorAvgMissingFieldNoDetailedErrors(t *testing.T) {
7677
LogMessageField: "line",
7778
LogLevelField: "lvl",
7879
}
79-
_, err := queryDataTestWithResponseCode(query, 400, response, configuredFields)
80-
// FIXME: add asserts to also test the result is containing an error with the 400 status code
80+
81+
result, err := queryDataTestWithResponseCode(query, 400, response, configuredFields)
8182
require.Nil(t, err)
83+
require.Contains(t, result.response.Responses["A"].Error.Error(), "\"status\":400")
8284
}
8385

8486
func TestErrorTooManyDateHistogramBuckets(t *testing.T) {
@@ -160,7 +162,8 @@ func TestNonElasticError(t *testing.T) {
160162
LogMessageField: "line",
161163
LogLevelField: "lvl",
162164
}
163-
_, err := queryDataTestWithResponseCode(query, 403, response, configuredFields)
164-
// FIXME: add asserts to also test the result is containing an error with the 403 status code
165+
166+
result, err := queryDataTestWithResponseCode(query, 403, response, configuredFields)
165167
require.Nil(t, err)
168+
require.Contains(t, result.response.Responses["A"].Error.Error(), "\"status\":403")
166169
}

0 commit comments

Comments
 (0)