summaryrefslogtreecommitdiffstats
path: root/integrations/api_issue_tracked_time_test.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-11-16 16:53:21 +0800
committerGitHub <noreply@github.com>2021-11-16 16:53:21 +0800
commit81926d61db3dac223a75ea49eab893b25a089587 (patch)
tree627d2f19a008089f3a688e9a94a2cc8d2017afe2 /integrations/api_issue_tracked_time_test.go
parent23bd7b1211a80aa3b0dcb60ec4a1c0089ff28dd4 (diff)
downloadgitea-81926d61db3dac223a75ea49eab893b25a089587.tar.gz
gitea-81926d61db3dac223a75ea49eab893b25a089587.zip
Decouple unit test, remove intermediate `unittestbridge` package (#17662)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'integrations/api_issue_tracked_time_test.go')
-rw-r--r--integrations/api_issue_tracked_time_test.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/integrations/api_issue_tracked_time_test.go b/integrations/api_issue_tracked_time_test.go
index fcf18e45df..bcaa0213c8 100644
--- a/integrations/api_issue_tracked_time_test.go
+++ b/integrations/api_issue_tracked_time_test.go
@@ -11,7 +11,7 @@ import (
"time"
"code.gitea.io/gitea/models"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
api "code.gitea.io/gitea/modules/structs"
"github.com/stretchr/testify/assert"
@@ -20,8 +20,8 @@ import (
func TestAPIGetTrackedTimes(t *testing.T) {
defer prepareTestEnv(t)()
- user2 := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
- issue2 := db.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
+ user2 := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
+ issue2 := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
assert.NoError(t, issue2.LoadRepo())
session := loginUser(t, user2.Name)
@@ -62,10 +62,10 @@ func TestAPIGetTrackedTimes(t *testing.T) {
func TestAPIDeleteTrackedTime(t *testing.T) {
defer prepareTestEnv(t)()
- time6 := db.AssertExistsAndLoadBean(t, &models.TrackedTime{ID: 6}).(*models.TrackedTime)
- issue2 := db.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
+ time6 := unittest.AssertExistsAndLoadBean(t, &models.TrackedTime{ID: 6}).(*models.TrackedTime)
+ issue2 := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
assert.NoError(t, issue2.LoadRepo())
- user2 := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
+ user2 := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
session := loginUser(t, user2.Name)
token := getTokenForLoggedInUser(t, session)
@@ -74,7 +74,7 @@ func TestAPIDeleteTrackedTime(t *testing.T) {
req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/times/%d?token=%s", user2.Name, issue2.Repo.Name, issue2.Index, time6.ID, token)
session.MakeRequest(t, req, http.StatusForbidden)
- time3 := db.AssertExistsAndLoadBean(t, &models.TrackedTime{ID: 3}).(*models.TrackedTime)
+ time3 := unittest.AssertExistsAndLoadBean(t, &models.TrackedTime{ID: 3}).(*models.TrackedTime)
req = NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/times/%d?token=%s", user2.Name, issue2.Repo.Name, issue2.Index, time3.ID, token)
session.MakeRequest(t, req, http.StatusNoContent)
//Delete non existing time
@@ -97,10 +97,10 @@ func TestAPIDeleteTrackedTime(t *testing.T) {
func TestAPIAddTrackedTimes(t *testing.T) {
defer prepareTestEnv(t)()
- issue2 := db.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
+ issue2 := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
assert.NoError(t, issue2.LoadRepo())
- user2 := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
- admin := db.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
+ user2 := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
+ admin := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
session := loginUser(t, admin.Name)
token := getTokenForLoggedInUser(t, session)