diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-11-12 22:36:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-12 22:36:47 +0800 |
commit | df64fa486555de6f403a795fd16c2e9e1d59e535 (patch) | |
tree | b899e9b9e5d57409b1bf0e3afbd606b6a3900235 /models/notification_test.go | |
parent | 7f802631c54d2e91301158380b273b872d62bd80 (diff) | |
download | gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.tar.gz gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.zip |
Decouple unit test code from business code (#17623)
Diffstat (limited to 'models/notification_test.go')
-rw-r--r-- | models/notification_test.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/models/notification_test.go b/models/notification_test.go index 588882bed3..cdba409f3d 100644 --- a/models/notification_test.go +++ b/models/notification_test.go @@ -8,11 +8,12 @@ import ( "testing" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" "github.com/stretchr/testify/assert" ) func TestCreateOrUpdateIssueNotifications(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) issue := db.AssertExistsAndLoadBean(t, &Issue{ID: 1}).(*Issue) assert.NoError(t, CreateOrUpdateIssueNotifications(issue.ID, 0, 2, 0)) @@ -27,7 +28,7 @@ func TestCreateOrUpdateIssueNotifications(t *testing.T) { } func TestNotificationsForUser(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) user := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) statuses := []NotificationStatus{NotificationStatusRead, NotificationStatusUnread} notfs, err := NotificationsForUser(user, statuses, 1, 10) @@ -43,7 +44,7 @@ func TestNotificationsForUser(t *testing.T) { } func TestNotification_GetRepo(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) notf := db.AssertExistsAndLoadBean(t, &Notification{RepoID: 1}).(*Notification) repo, err := notf.GetRepo() assert.NoError(t, err) @@ -52,7 +53,7 @@ func TestNotification_GetRepo(t *testing.T) { } func TestNotification_GetIssue(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) notf := db.AssertExistsAndLoadBean(t, &Notification{RepoID: 1}).(*Notification) issue, err := notf.GetIssue() assert.NoError(t, err) @@ -61,7 +62,7 @@ func TestNotification_GetIssue(t *testing.T) { } func TestGetNotificationCount(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) user := db.AssertExistsAndLoadBean(t, &User{ID: 1}).(*User) cnt, err := GetNotificationCount(user, NotificationStatusRead) assert.NoError(t, err) @@ -73,7 +74,7 @@ func TestGetNotificationCount(t *testing.T) { } func TestSetNotificationStatus(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) user := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) notf := db.AssertExistsAndLoadBean(t, &Notification{UserID: user.ID, Status: NotificationStatusRead}).(*Notification) @@ -89,7 +90,7 @@ func TestSetNotificationStatus(t *testing.T) { } func TestUpdateNotificationStatuses(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) user := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) notfUnread := db.AssertExistsAndLoadBean(t, &Notification{UserID: user.ID, Status: NotificationStatusUnread}).(*Notification) |