diff options
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) } |