@@ -199,6 +199,90 @@ func TestUserResolver_ResolveUsers(t *testing.T) {
199199 }
200200}
201201
202+ func TestUserResolver_ResolvePeople (t * testing.T ) {
203+ people := []api.Person {
204+ {ID : 1 , Name : "John Doe" , EmailAddress : "john@example.com" , AttachableSGID : "sgid-john" },
205+ {ID : 2 , Name : "Jane Smith" , EmailAddress : "jane@example.com" , AttachableSGID : "sgid-jane" },
206+ {ID : 3 , Name : "Bob Johnson" , EmailAddress : "bob@company.com" , AttachableSGID : "sgid-bob" },
207+ }
208+
209+ tests := []struct {
210+ name string
211+ identifiers []string
212+ mockPeople []api.Person
213+ mockError error
214+ expectPeople []api.Person
215+ expectError bool
216+ }{
217+ {
218+ name : "Resolve single person by name" ,
219+ identifiers : []string {"John" },
220+ mockPeople : people ,
221+ expectPeople : []api.Person {people [0 ]},
222+ expectError : false ,
223+ },
224+ {
225+ name : "Resolve multiple people" ,
226+ identifiers : []string {"John" , "Jane" },
227+ mockPeople : people ,
228+ expectPeople : []api.Person {people [0 ], people [1 ]},
229+ expectError : false ,
230+ },
231+ {
232+ name : "Not found error" ,
233+ identifiers : []string {"Unknown" },
234+ mockPeople : people ,
235+ expectError : true ,
236+ },
237+ {
238+ name : "API error" ,
239+ identifiers : []string {"John" },
240+ mockError : errors .New ("API error" ),
241+ expectError : true ,
242+ },
243+ {
244+ name : "Empty identifier treated as not found" ,
245+ identifiers : []string {"" },
246+ mockPeople : people ,
247+ expectError : true ,
248+ },
249+ }
250+
251+ for _ , tt := range tests {
252+ t .Run (tt .name , func (t * testing.T ) {
253+ mockClient := mock .NewMockClient ()
254+ mockClient .People = tt .mockPeople
255+ mockClient .PeopleError = tt .mockError
256+
257+ resolver := NewUserResolver (mockClient , "12345" )
258+ ctx := context .Background ()
259+
260+ result , err := resolver .ResolvePeople (ctx , tt .identifiers )
261+
262+ if tt .expectError && err == nil {
263+ t .Error ("Expected error but got none" )
264+ }
265+ if ! tt .expectError && err != nil {
266+ t .Errorf ("Unexpected error: %v" , err )
267+ }
268+
269+ if ! tt .expectError {
270+ if len (result ) != len (tt .expectPeople ) {
271+ t .Fatalf ("Expected %d people, got %d" , len (tt .expectPeople ), len (result ))
272+ }
273+ for i , p := range result {
274+ if p .ID != tt .expectPeople [i ].ID {
275+ t .Errorf ("Expected person[%d].ID = %d, got %d" , i , tt .expectPeople [i ].ID , p .ID )
276+ }
277+ if p .AttachableSGID != tt .expectPeople [i ].AttachableSGID {
278+ t .Errorf ("Expected person[%d].AttachableSGID = %q, got %q" , i , tt .expectPeople [i ].AttachableSGID , p .AttachableSGID )
279+ }
280+ }
281+ }
282+ })
283+ }
284+ }
285+
202286func TestUserResolver_resolveIdentifier (t * testing.T ) {
203287 // Create test people
204288 ur := & UserResolver {
0 commit comments