aboutsummaryrefslogtreecommitdiffstats
path: root/models/db/list_test.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-04-19 21:40:42 +0800
committerGitHub <noreply@github.com>2023-04-19 21:40:42 +0800
commite422342eebc18034ef586ec58f1e2fff0340091d (patch)
tree307264b46c1683915429083d54e9634ee4f2fc4d /models/db/list_test.go
parent01214c8ada993bf5f54a4149979d140443d69410 (diff)
downloadgitea-e422342eebc18034ef586ec58f1e2fff0340091d.tar.gz
gitea-e422342eebc18034ef586ec58f1e2fff0340091d.zip
Allow adding new files to an empty repo (#24164)
![image](https://user-images.githubusercontent.com/2114189/232561612-2bfcfd0a-fc04-47ba-965f-5d0bcea46c54.png)
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)