Set Content-Type in test and handle error earlier
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user