aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo/topic_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-03-29 11:38:16 +0800
committerGitHub <noreply@github.com>2024-03-29 11:38:16 +0800
commit8acc7aab4c254c4819f45e512b86cf5a4255091f (patch)
treef99c44d3af0198977f1b5685bef7d56154beb812 /models/repo/topic_test.go
parentdd8dde2be89921b2b1497c6cc5eafdde213429cb (diff)
downloadgitea-8acc7aab4c254c4819f45e512b86cf5a4255091f.tar.gz
gitea-8acc7aab4c254c4819f45e512b86cf5a4255091f.zip
Refactor topic Find functions and add more tests for pagination (#30127)
This also fixed #22238
Diffstat (limited to 'models/repo/topic_test.go')
-rw-r--r--models/repo/topic_test.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/models/repo/topic_test.go b/models/repo/topic_test.go
index 2b609e6d66..1600896b6e 100644
--- a/models/repo/topic_test.go
+++ b/models/repo/topic_test.go
@@ -19,18 +19,18 @@ func TestAddTopic(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- topics, _, err := repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{})
+ topics, err := db.Find[repo_model.Topic](db.DefaultContext, &repo_model.FindTopicOptions{})
assert.NoError(t, err)
assert.Len(t, topics, totalNrOfTopics)
- topics, total, err := repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{
+ topics, total, err := db.FindAndCount[repo_model.Topic](db.DefaultContext, &repo_model.FindTopicOptions{
ListOptions: db.ListOptions{Page: 1, PageSize: 2},
})
assert.NoError(t, err)
assert.Len(t, topics, 2)
assert.EqualValues(t, 6, total)
- topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{
+ topics, err = db.Find[repo_model.Topic](db.DefaultContext, &repo_model.FindTopicOptions{
RepoID: 1,
})
assert.NoError(t, err)
@@ -38,11 +38,11 @@ func TestAddTopic(t *testing.T) {
assert.NoError(t, repo_model.SaveTopics(db.DefaultContext, 2, "golang"))
repo2NrOfTopics := 1
- topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{})
+ topics, err = db.Find[repo_model.Topic](db.DefaultContext, &repo_model.FindTopicOptions{})
assert.NoError(t, err)
assert.Len(t, topics, totalNrOfTopics)
- topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{
+ topics, err = db.Find[repo_model.Topic](db.DefaultContext, &repo_model.FindTopicOptions{
RepoID: 2,
})
assert.NoError(t, err)
@@ -55,11 +55,11 @@ func TestAddTopic(t *testing.T) {
assert.NoError(t, err)
assert.EqualValues(t, 1, topic.RepoCount)
- topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{})
+ topics, err = db.Find[repo_model.Topic](db.DefaultContext, &repo_model.FindTopicOptions{})
assert.NoError(t, err)
assert.Len(t, topics, totalNrOfTopics)
- topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{
+ topics, err = db.Find[repo_model.Topic](db.DefaultContext, &repo_model.FindTopicOptions{
RepoID: 2,
})
assert.NoError(t, err)