From 08fbacc7e651c59192e7701c3d3b7d2eeffbf35c Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Sun, 21 Aug 2022 19:41:04 +0000 Subject: [PATCH] Set Content-Type in test and handle error earlier --- server/account_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/account_test.go b/server/account_test.go index 1540ff3..f0f9795 100644 --- a/server/account_test.go +++ b/server/account_test.go @@ -39,13 +39,19 @@ func TestRegisterUser(t *testing.T) { http.MethodPost, "/api/v1/user/register", strings.NewReader(`{"password":"pass","email":"info@example.com","name":"Test"}`)) + request.Header.Set("Content-Type", "application/json") context := engine.NewContext(request, recorder) if err != nil { t.Errorf("error creating request: %s", err) return } - h.registerPost(context) + err = h.registerPost(context) + if err != nil { + t.Error(err.Error()) + t.Error("Error registering") + return + } if recorder.Code != http.StatusOK { t.Errorf("handler returned wrong status code: got %v want %v", recorder.Code, http.StatusOK)