aboutsummaryrefslogtreecommitdiffstats
path: root/models/db/list_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/db/list_test.go')
-rw-r--r--models/db/list_test.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/models/db/list_test.go b/models/db/list_test.go
index 195450b1e7..6b9bebd64b 100644
--- a/models/db/list_test.go
+++ b/models/db/list_test.go
@@ -31,15 +31,20 @@ func TestFind(t *testing.T) {
xe := unittest.GetXORMEngine()
assert.NoError(t, xe.Sync(&repo_model.RepoUnit{}))
+ var repoUnitCount int
+ _, err := db.GetEngine(db.DefaultContext).SQL("SELECT COUNT(*) FROM repo_unit").Get(&repoUnitCount)
+ assert.NoError(t, err)
+ assert.NotEmpty(t, repoUnitCount)
+
opts := mockListOptions{}
var repoUnits []repo_model.RepoUnit
- err := db.Find(db.DefaultContext, &opts, &repoUnits)
+ err = db.Find(db.DefaultContext, &opts, &repoUnits)
assert.NoError(t, err)
- assert.EqualValues(t, 89, len(repoUnits))
+ assert.EqualValues(t, repoUnitCount, len(repoUnits))
cnt, err := db.Count(db.DefaultContext, &opts, new(repo_model.RepoUnit))
assert.NoError(t, err)
- assert.EqualValues(t, 89, cnt)
+ assert.EqualValues(t, repoUnitCount, cnt)
repoUnits = make([]repo_model.RepoUnit, 0, 10)
newCnt, err := db.FindAndCount(db.DefaultContext, &opts, &repoUnits)