From c0371650ecd664a72bfb5c3b31671c8e91a3df1f Mon Sep 17 00:00:00 2001 From: Idriss Neumann Date: Mon, 27 Nov 2023 16:24:45 +0100 Subject: [PATCH] Issue #28: improve asserts in unit tests --- pkg/quickwit/error_handling_test.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/quickwit/error_handling_test.go b/pkg/quickwit/error_handling_test.go index 75519c0..7ce7c21 100644 --- a/pkg/quickwit/error_handling_test.go +++ b/pkg/quickwit/error_handling_test.go @@ -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) { @@ -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) { @@ -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") }