Set Content-Type in test and handle error earlier
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Jan Bader 2022-08-21 19:41:04 +00:00
parent 1c003486ca
commit 08fbacc7e6

View File

@ -39,13 +39,19 @@ func TestRegisterUser(t *testing.T) {
http.MethodPost, http.MethodPost,
"/api/v1/user/register", "/api/v1/user/register",
strings.NewReader(`{"password":"pass","email":"info@example.com","name":"Test"}`)) strings.NewReader(`{"password":"pass","email":"info@example.com","name":"Test"}`))
request.Header.Set("Content-Type", "application/json")
context := engine.NewContext(request, recorder) context := engine.NewContext(request, recorder)
if err != nil { if err != nil {
t.Errorf("error creating request: %s", err) t.Errorf("error creating request: %s", err)
return 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 { if recorder.Code != http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v", recorder.Code, http.StatusOK) t.Errorf("handler returned wrong status code: got %v want %v", recorder.Code, http.StatusOK)