diff options
Diffstat (limited to 'models/admin_test.go')
-rw-r--r-- | models/admin_test.go | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/models/admin_test.go b/models/admin_test.go index b4383cb2d3..316ed5cb68 100644 --- a/models/admin_test.go +++ b/models/admin_test.go @@ -7,6 +7,7 @@ package models import ( "testing" + "code.gitea.io/gitea/models/db" "github.com/stretchr/testify/assert" ) @@ -19,38 +20,38 @@ func TestNotice_TrStr(t *testing.T) { } func TestCreateNotice(t *testing.T) { - assert.NoError(t, PrepareTestDatabase()) + assert.NoError(t, db.PrepareTestDatabase()) noticeBean := &Notice{ Type: NoticeRepository, Description: "test description", } - AssertNotExistsBean(t, noticeBean) + db.AssertNotExistsBean(t, noticeBean) assert.NoError(t, CreateNotice(noticeBean.Type, noticeBean.Description)) - AssertExistsAndLoadBean(t, noticeBean) + db.AssertExistsAndLoadBean(t, noticeBean) } func TestCreateRepositoryNotice(t *testing.T) { - assert.NoError(t, PrepareTestDatabase()) + assert.NoError(t, db.PrepareTestDatabase()) noticeBean := &Notice{ Type: NoticeRepository, Description: "test description", } - AssertNotExistsBean(t, noticeBean) + db.AssertNotExistsBean(t, noticeBean) assert.NoError(t, CreateRepositoryNotice(noticeBean.Description)) - AssertExistsAndLoadBean(t, noticeBean) + db.AssertExistsAndLoadBean(t, noticeBean) } // TODO TestRemoveAllWithNotice func TestCountNotices(t *testing.T) { - assert.NoError(t, PrepareTestDatabase()) + assert.NoError(t, db.PrepareTestDatabase()) assert.Equal(t, int64(3), CountNotices()) } func TestNotices(t *testing.T) { - assert.NoError(t, PrepareTestDatabase()) + assert.NoError(t, db.PrepareTestDatabase()) notices, err := Notices(1, 2) assert.NoError(t, err) @@ -67,47 +68,47 @@ func TestNotices(t *testing.T) { } func TestDeleteNotice(t *testing.T) { - assert.NoError(t, PrepareTestDatabase()) + assert.NoError(t, db.PrepareTestDatabase()) - AssertExistsAndLoadBean(t, &Notice{ID: 3}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 3}) assert.NoError(t, DeleteNotice(3)) - AssertNotExistsBean(t, &Notice{ID: 3}) + db.AssertNotExistsBean(t, &Notice{ID: 3}) } func TestDeleteNotices(t *testing.T) { // delete a non-empty range - assert.NoError(t, PrepareTestDatabase()) + assert.NoError(t, db.PrepareTestDatabase()) - AssertExistsAndLoadBean(t, &Notice{ID: 1}) - AssertExistsAndLoadBean(t, &Notice{ID: 2}) - AssertExistsAndLoadBean(t, &Notice{ID: 3}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 1}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 2}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 3}) assert.NoError(t, DeleteNotices(1, 2)) - AssertNotExistsBean(t, &Notice{ID: 1}) - AssertNotExistsBean(t, &Notice{ID: 2}) - AssertExistsAndLoadBean(t, &Notice{ID: 3}) + db.AssertNotExistsBean(t, &Notice{ID: 1}) + db.AssertNotExistsBean(t, &Notice{ID: 2}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 3}) } func TestDeleteNotices2(t *testing.T) { // delete an empty range - assert.NoError(t, PrepareTestDatabase()) + assert.NoError(t, db.PrepareTestDatabase()) - AssertExistsAndLoadBean(t, &Notice{ID: 1}) - AssertExistsAndLoadBean(t, &Notice{ID: 2}) - AssertExistsAndLoadBean(t, &Notice{ID: 3}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 1}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 2}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 3}) assert.NoError(t, DeleteNotices(3, 2)) - AssertExistsAndLoadBean(t, &Notice{ID: 1}) - AssertExistsAndLoadBean(t, &Notice{ID: 2}) - AssertExistsAndLoadBean(t, &Notice{ID: 3}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 1}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 2}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 3}) } func TestDeleteNoticesByIDs(t *testing.T) { - assert.NoError(t, PrepareTestDatabase()) + assert.NoError(t, db.PrepareTestDatabase()) - AssertExistsAndLoadBean(t, &Notice{ID: 1}) - AssertExistsAndLoadBean(t, &Notice{ID: 2}) - AssertExistsAndLoadBean(t, &Notice{ID: 3}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 1}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 2}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 3}) assert.NoError(t, DeleteNoticesByIDs([]int64{1, 3})) - AssertNotExistsBean(t, &Notice{ID: 1}) - AssertExistsAndLoadBean(t, &Notice{ID: 2}) - AssertNotExistsBean(t, &Notice{ID: 3}) + db.AssertNotExistsBean(t, &Notice{ID: 1}) + db.AssertExistsAndLoadBean(t, &Notice{ID: 2}) + db.AssertNotExistsBean(t, &Notice{ID: 3}) } |