diff --git a/routes/currentUser_test.go b/routes/currentUser_test.go index da62708..4ac993e 100644 --- a/routes/currentUser_test.go +++ b/routes/currentUser_test.go @@ -131,3 +131,28 @@ func TestErrorUserContextNoUserID(t *testing.T) { assert.Equal(http.StatusInternalServerError, status) } + +func TestSingleUserErrorWriter(t *testing.T) { + // set up + assert := assert.New(t) + m := getEmptyModel() + + idToUse := 1 + username := "testing_username" + displayName := "testing_name" + password := "pass" + m.CreateUser(&models.CreateUserRequest{Username: username, DisplayName: displayName, Password: password}) + + router := routes.NewCurrentUserRouter(m) + req, _ := http.NewRequestWithContext(tokens.GetContextForUserValues(idToUse, username), "GET", "/", nil) + + rr := NewBadWriter() + + // function under test + router.ServeHTTP(rr, req) + + // check results + status := rr.Code + assert.Equal(http.StatusInternalServerError, status) + +}