MCPcopy Index your code
hub / github.com/github/github-mcp-server / Test_ProjectsList_ListProjects

Function Test_ProjectsList_ListProjects

pkg/github/projects_test.go:37–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func Test_ProjectsList_ListProjects(t *testing.T) {
38 toolDef := ProjectsList(translations.NullTranslationHelper)
39
40 orgProjects := []map[string]any{{"id": 1, "node_id": "NODE1", "title": "Org Project"}}
41 userProjects := []map[string]any{{"id": 2, "node_id": "NODE2", "title": "User Project"}}
42
43 tests := []struct {
44 name string
45 mockedClient *http.Client
46 requestArgs map[string]any
47 expectError bool
48 expectedErrMsg string
49 expectedLength int
50 }{
51 {
52 name: "success organization",
53 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
54 GetOrgsProjectsV2: mockResponse(t, http.StatusOK, orgProjects),
55 }),
56 requestArgs: map[string]any{
57 "method": "list_projects",
58 "owner": "octo-org",
59 "owner_type": "org",
60 },
61 expectError: false,
62 expectedLength: 1,
63 },
64 {
65 name: "success user",
66 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
67 GetUsersProjectsV2ByUsername: mockResponse(t, http.StatusOK, userProjects),
68 }),
69 requestArgs: map[string]any{
70 "method": "list_projects",
71 "owner": "octocat",
72 "owner_type": "user",
73 },
74 expectError: false,
75 expectedLength: 1,
76 },
77 {
78 name: "missing required parameter method",
79 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{}),
80 requestArgs: map[string]any{
81 "owner": "octo-org",
82 "owner_type": "org",
83 },
84 expectError: true,
85 expectedErrMsg: "missing required parameter: method",
86 },
87 {
88 name: "unknown method",
89 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{}),
90 requestArgs: map[string]any{
91 "method": "unknown_method",
92 "owner": "octo-org",
93 "owner_type": "org",
94 },

Callers

nothing calls this directly

Calls 8

ProjectsListFunction · 0.85
mockResponseFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
HandlerMethod · 0.45

Tested by

no test coverage detected