diff options
author | Lanre Adelowo <adelowomailbox@gmail.com> | 2019-06-06 01:37:45 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-06-06 08:37:45 +0800 |
commit | de6539fc8c37485afcd6f30092a9ccbc3cae7de5 (patch) | |
tree | 02aec172ffe99ac123b56b301c70774f1f3f1292 /models/issue_milestone_test.go | |
parent | 59e6a7b97f503c12ef2a6096ca7f127f81521b7a (diff) | |
download | gitea-de6539fc8c37485afcd6f30092a9ccbc3cae7de5.tar.gz gitea-de6539fc8c37485afcd6f30092a9ccbc3cae7de5.zip |
Add state param to milestone listing API (#7131)
* Support state params
* update tests
* fix tests
* add state=all support
* update tests
* update swagger
* update swagger
Diffstat (limited to 'models/issue_milestone_test.go')
-rw-r--r-- | models/issue_milestone_test.go | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/models/issue_milestone_test.go b/models/issue_milestone_test.go index fb1ee8b7a5..f9e51aff31 100644 --- a/models/issue_milestone_test.go +++ b/models/issue_milestone_test.go @@ -69,20 +69,43 @@ func TestGetMilestoneByRepoID(t *testing.T) { func TestGetMilestonesByRepoID(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) - test := func(repoID int64) { + test := func(repoID int64, state api.StateType) { repo := AssertExistsAndLoadBean(t, &Repository{ID: repoID}).(*Repository) - milestones, err := GetMilestonesByRepoID(repo.ID) + milestones, err := GetMilestonesByRepoID(repo.ID, state) assert.NoError(t, err) - assert.Len(t, milestones, repo.NumMilestones) + + var n int + + switch state { + case api.StateClosed: + n = repo.NumClosedMilestones + + case api.StateAll: + n = repo.NumMilestones + + case api.StateOpen: + fallthrough + + default: + n = repo.NumOpenMilestones + } + + assert.Len(t, milestones, n) for _, milestone := range milestones { assert.EqualValues(t, repoID, milestone.RepoID) } } - test(1) - test(2) - test(3) - - milestones, err := GetMilestonesByRepoID(NonexistentID) + test(1, api.StateOpen) + test(1, api.StateAll) + test(1, api.StateClosed) + test(2, api.StateOpen) + test(2, api.StateAll) + test(2, api.StateClosed) + test(3, api.StateOpen) + test(3, api.StateClosed) + test(3, api.StateAll) + + milestones, err := GetMilestonesByRepoID(NonexistentID, api.StateOpen) assert.NoError(t, err) assert.Len(t, milestones, 0) } |