summaryrefslogtreecommitdiffstats
path: root/integrations/api_token_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'integrations/api_token_test.go')
-rw-r--r--integrations/api_token_test.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/integrations/api_token_test.go b/integrations/api_token_test.go
index 1a6d53547b..8314d5b636 100644
--- a/integrations/api_token_test.go
+++ b/integrations/api_token_test.go
@@ -9,14 +9,14 @@ import (
"testing"
"code.gitea.io/gitea/models"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
api "code.gitea.io/gitea/modules/structs"
)
// TestAPICreateAndDeleteToken tests that token that was just created can be deleted
func TestAPICreateAndDeleteToken(t *testing.T) {
defer prepareTestEnv(t)()
- user := db.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
+ user := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
req := NewRequestWithJSON(t, "POST", "/api/v1/users/user1/tokens", map[string]string{
"name": "test-key-1",
@@ -26,7 +26,7 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
var newAccessToken api.AccessToken
DecodeJSON(t, resp, &newAccessToken)
- db.AssertExistsAndLoadBean(t, &models.AccessToken{
+ unittest.AssertExistsAndLoadBean(t, &models.AccessToken{
ID: newAccessToken.ID,
Name: newAccessToken.Name,
Token: newAccessToken.Token,
@@ -37,7 +37,7 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
req = AddBasicAuthHeader(req, user.Name)
MakeRequest(t, req, http.StatusNoContent)
- db.AssertNotExistsBean(t, &models.AccessToken{ID: newAccessToken.ID})
+ unittest.AssertNotExistsBean(t, &models.AccessToken{ID: newAccessToken.ID})
req = NewRequestWithJSON(t, "POST", "/api/v1/users/user1/tokens", map[string]string{
"name": "test-key-2",
@@ -50,15 +50,15 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
req = AddBasicAuthHeader(req, user.Name)
MakeRequest(t, req, http.StatusNoContent)
- db.AssertNotExistsBean(t, &models.AccessToken{ID: newAccessToken.ID})
+ unittest.AssertNotExistsBean(t, &models.AccessToken{ID: newAccessToken.ID})
}
// TestAPIDeleteMissingToken ensures that error is thrown when token not found
func TestAPIDeleteMissingToken(t *testing.T) {
defer prepareTestEnv(t)()
- user := db.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
+ user := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
- req := NewRequestf(t, "DELETE", "/api/v1/users/user1/tokens/%d", db.NonexistentID)
+ req := NewRequestf(t, "DELETE", "/api/v1/users/user1/tokens/%d", unittest.NonexistentID)
req = AddBasicAuthHeader(req, user.Name)
MakeRequest(t, req, http.StatusNotFound)
}