@@ -19,6 +19,8 @@ package icassigner
1919import (
2020 "fmt"
2121 "testing"
22+
23+ "github.com/google/go-github/github"
2224)
2325
2426func TestFindTeam (t * testing.T ) {
@@ -93,3 +95,69 @@ func TestFindTeam(t *testing.T) {
9395 })
9496 }
9597}
98+
99+ func TestIsTeamMemberAssigned (t * testing.T ) {
100+ teamMembers := []MemberConfig {
101+ {Name : "Alice" },
102+ {Name : "Bob" },
103+ {Name : "Charlie" },
104+ }
105+
106+ testCases := []struct {
107+ name string
108+ teamMembers []MemberConfig
109+ assignees []* github.User
110+ expectedResult bool
111+ expectedName string
112+ }{
113+ {
114+ name : "No assignees" ,
115+ teamMembers : teamMembers ,
116+ assignees : []* github.User {},
117+ expectedResult : false ,
118+ expectedName : "" ,
119+ },
120+ {
121+ name : "Assignee matches team member" ,
122+ teamMembers : teamMembers ,
123+ assignees : []* github.User {{Login : github .String ("Alice" )}},
124+ expectedResult : true ,
125+ expectedName : "Alice" ,
126+ },
127+ {
128+ name : "Case-insensitive match" ,
129+ teamMembers : teamMembers ,
130+ assignees : []* github.User {{Login : github .String ("bob" )}},
131+ expectedResult : true ,
132+ expectedName : "Bob" ,
133+ },
134+ {
135+ name : "No matching assignees" ,
136+ teamMembers : teamMembers ,
137+ assignees : []* github.User {{Login : github .String ("Unknown" )}},
138+ expectedResult : false ,
139+ expectedName : "" ,
140+ },
141+ {
142+ name : "Multiple assignees, one matches" ,
143+ teamMembers : teamMembers ,
144+ assignees : []* github.User {{Login : github .String ("Unknown" )}, {Login : github .String ("Charlie" )}},
145+ expectedResult : true ,
146+ expectedName : "Charlie" ,
147+ },
148+ }
149+
150+ for _ , testCase := range testCases {
151+ t .Run (testCase .name , func (t * testing.T ) {
152+ result , name := isTeamMemberAssigned (testCase .teamMembers , testCase .assignees )
153+
154+ if result != testCase .expectedResult {
155+ t .Errorf ("Expected result to be %v, but got %v" , testCase .expectedResult , result )
156+ }
157+
158+ if name != testCase .expectedName {
159+ t .Errorf ("Expected name to be %q, but got %q" , testCase .expectedName , name )
160+ }
161+ })
162+ }
163+ }
0 commit comments