Adds last currentUser route tests
All checks were successful
gitea-deepak/gogmagog/pipeline/head This commit looks good

This commit is contained in:
Deepak Mallubhotla 2021-01-25 15:00:07 -06:00
parent 63a9e2ff58
commit c9675b1573
Signed by: deepak
GPG Key ID: 64BF53A3369104E7

View File

@ -131,3 +131,28 @@ func TestErrorUserContextNoUserID(t *testing.T) {
assert.Equal(http.StatusInternalServerError, status) 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)
}