MCPcopy
hub / github.com/github/github-mcp-server / Test_GetTeamMembers

Function Test_GetTeamMembers

pkg/github/context_tools_test.go:451–584  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

449}
450
451func Test_GetTeamMembers(t *testing.T) {
452 t.Parallel()
453
454 serverTool := GetTeamMembers(translations.NullTranslationHelper)
455 tool := serverTool.Tool
456 require.NoError(t, toolsnaps.Test(tool.Name, tool))
457
458 assert.Equal(t, "get_team_members", tool.Name)
459 assert.True(t, tool.Annotations.ReadOnlyHint, "get_team_members tool should be read-only")
460
461 mockTeamMembersResponse := githubv4mock.DataResponse(map[string]any{
462 "organization": map[string]any{
463 "team": map[string]any{
464 "members": map[string]any{
465 "nodes": []map[string]any{
466 {
467 "login": "user1",
468 },
469 {
470 "login": "user2",
471 },
472 },
473 },
474 },
475 },
476 })
477
478 mockNoMembersResponse := githubv4mock.DataResponse(map[string]any{
479 "organization": map[string]any{
480 "team": map[string]any{
481 "members": map[string]any{
482 "nodes": []map[string]any{},
483 },
484 },
485 },
486 })
487
488 // Create GQL clients for different test scenarios
489 gqlClientWithMembers := func() *githubv4.Client {
490 queryStr := "query($org:String!$teamSlug:String!){organization(login: $org){team(slug: $teamSlug){members(first: 100){nodes{login}}}}}"
491 vars := map[string]any{
492 "org": "testorg",
493 "teamSlug": "testteam",
494 }
495 matcher := githubv4mock.NewQueryMatcher(queryStr, vars, mockTeamMembersResponse)
496 httpClient := githubv4mock.NewMockedHTTPClient(matcher)
497 return githubv4.NewClient(httpClient)
498 }
499
500 gqlClientNoMembers := func() *githubv4.Client {
501 queryStr := "query($org:String!$teamSlug:String!){organization(login: $org){team(slug: $teamSlug){members(first: 100){nodes{login}}}}}"
502 vars := map[string]any{
503 "org": "testorg",
504 "teamSlug": "emptyteam",
505 }
506 matcher := githubv4mock.NewQueryMatcher(queryStr, vars, mockNoMembersResponse)
507 httpClient := githubv4mock.NewMockedHTTPClient(matcher)
508 return githubv4.NewClient(httpClient)

Callers

nothing calls this directly

Calls 12

TestFunction · 0.92
DataResponseFunction · 0.92
NewQueryMatcherFunction · 0.92
NewMockedHTTPClientFunction · 0.92
GetTeamMembersFunction · 0.85
stubGQLClientFnErrFunction · 0.85
stubExportersFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85
getTextResultFunction · 0.85
HandlerMethod · 0.45

Tested by

no test coverage detected