From 2c4a36376d6522f6d82b756762b539b10b9b1ab6 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 28 Apr 2024 19:57:48 +0100 Subject: [PATCH] tests: API: simplify check of error response Since we already use require.JSONEq in similar cases. Signed-off-by: Bryan Boreham --- web/api/v1/api_test.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index c38399381..9c45fd5d5 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -3292,18 +3292,7 @@ func TestRespondError(t *testing.T) { require.Equal(t, want, have, "Return code %d expected in error response but got %d", want, have) h := resp.Header.Get("Content-Type") require.Equal(t, "application/json", h, "Expected Content-Type %q but got %q", "application/json", h) - - var res Response - err = json.Unmarshal(body, &res) - require.NoError(t, err, "Error unmarshaling JSON body") - - exp := &Response{ - Status: statusError, - Data: "test", - ErrorType: errorTimeout, - Error: "message", - } - require.Equal(t, exp, &res) + require.JSONEq(t, `{"status": "error", "data": "test", "errorType": "timeout", "error": "message"}`, string(body)) } func TestParseTimeParam(t *testing.T) {