diff options
Diffstat (limited to 'models/issue_test.go')
-rw-r--r-- | models/issue_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/models/issue_test.go b/models/issue_test.go index 7c80258c2b..52724d07d4 100644 --- a/models/issue_test.go +++ b/models/issue_test.go @@ -5,6 +5,7 @@ package models import ( + "sort" "testing" "github.com/stretchr/testify/assert" @@ -58,3 +59,26 @@ func TestGetIssuesByIDs(t *testing.T) { testSuccess([]int64{1, 2, 3}, []int64{}) testSuccess([]int64{1, 2, 3}, []int64{NonexistentID}) } + +func TestGetParticipantsByIssueID(t *testing.T) { + + assert.NoError(t, PrepareTestDatabase()) + + checkPartecipants := func(issueID int64, userIDs []int) { + partecipants, err := GetParticipantsByIssueID(issueID) + if assert.NoError(t, err) { + partecipantsIDs := make([]int,len(partecipants)) + for i,u := range partecipants { partecipantsIDs[i] = int(u.ID) } + sort.Ints(partecipantsIDs) + sort.Ints(userIDs) + assert.Equal(t, userIDs, partecipantsIDs) + } + + } + + // User 1 is issue1 poster (see fixtures/issue.yml) + // User 2 only labeled issue1 (see fixtures/comment.yml) + // Users 3 and 5 made actual comments (see fixtures/comment.yml) + checkPartecipants(1, []int{3,5}) + +} |