mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 16:43:21 +00:00
tests: API: simplify check of error response
Since we already use require.JSONEq in similar cases. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
29505211af
commit
2c4a36376d
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user