diff options
author | 6543 <6543@obermui.de> | 2020-07-28 13:30:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-28 12:30:40 +0100 |
commit | 8bdc9795d8a5aa51bc1295dd1cf57006a5873343 (patch) | |
tree | 81ebd17da66318ca7909284021319be10a552e5c /models/issue_milestone_test.go | |
parent | 78cbd0ca72619a25849edc3460ec0c492b838a59 (diff) | |
download | gitea-8bdc9795d8a5aa51bc1295dd1cf57006a5873343.tar.gz gitea-8bdc9795d8a5aa51bc1295dd1cf57006a5873343.zip |
Add name filter to API for GetMilestoneList (#12336)
Adds a name filter to the API for GetMilestoneList
Includes a small refactor: merge GetMilestones and GetMilestonesByRepoID
Close #12260
Needed for https://gitea.com/gitea/go-sdk/issues/383 and https://gitea.com/gitea/tea/pulls/149
Diffstat (limited to 'models/issue_milestone_test.go')
-rw-r--r-- | models/issue_milestone_test.go | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/models/issue_milestone_test.go b/models/issue_milestone_test.go index 07dd8d57c5..af264aa274 100644 --- a/models/issue_milestone_test.go +++ b/models/issue_milestone_test.go @@ -8,6 +8,7 @@ import ( "sort" "testing" + "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" @@ -49,7 +50,10 @@ func TestGetMilestonesByRepoID(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) test := func(repoID int64, state api.StateType) { repo := AssertExistsAndLoadBean(t, &Repository{ID: repoID}).(*Repository) - milestones, err := GetMilestonesByRepoID(repo.ID, state, ListOptions{}) + milestones, err := GetMilestones(GetMilestonesOption{ + RepoID: repo.ID, + State: state, + }) assert.NoError(t, err) var n int @@ -83,7 +87,10 @@ func TestGetMilestonesByRepoID(t *testing.T) { test(3, api.StateClosed) test(3, api.StateAll) - milestones, err := GetMilestonesByRepoID(NonexistentID, api.StateOpen, ListOptions{}) + milestones, err := GetMilestones(GetMilestonesOption{ + RepoID: NonexistentID, + State: api.StateOpen, + }) assert.NoError(t, err) assert.Len(t, milestones, 0) } @@ -93,7 +100,15 @@ func TestGetMilestones(t *testing.T) { repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository) test := func(sortType string, sortCond func(*Milestone) int) { for _, page := range []int{0, 1} { - milestones, err := GetMilestones(repo.ID, page, false, sortType) + milestones, err := GetMilestones(GetMilestonesOption{ + ListOptions: ListOptions{ + Page: page, + PageSize: setting.UI.IssuePagingNum, + }, + RepoID: repo.ID, + State: api.StateOpen, + SortType: sortType, + }) assert.NoError(t, err) assert.Len(t, milestones, repo.NumMilestones-repo.NumClosedMilestones) values := make([]int, len(milestones)) @@ -102,7 +117,16 @@ func TestGetMilestones(t *testing.T) { } assert.True(t, sort.IntsAreSorted(values)) - milestones, err = GetMilestones(repo.ID, page, true, sortType) + milestones, err = GetMilestones(GetMilestonesOption{ + ListOptions: ListOptions{ + Page: page, + PageSize: setting.UI.IssuePagingNum, + }, + RepoID: repo.ID, + State: api.StateClosed, + Name: "", + SortType: sortType, + }) assert.NoError(t, err) assert.Len(t, milestones, repo.NumClosedMilestones) values = make([]int, len(milestones)) |