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

Function Test_ProjectsList_ListProjectFields

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

Source from the content-addressed store, hash-verified

130}
131
132func Test_ProjectsList_ListProjectFields(t *testing.T) {
133 toolDef := ProjectsList(translations.NullTranslationHelper)
134
135 fields := []map[string]any{{"id": 101, "name": "Status", "data_type": "single_select"}}
136
137 t.Run("success organization", func(t *testing.T) {
138 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
139 GetOrgsProjectsV2FieldsByProject: mockResponse(t, http.StatusOK, fields),
140 })
141
142 client := mustNewGHClient(t, mockedClient)
143 deps := BaseDeps{
144 Client: client,
145 }
146 handler := toolDef.Handler(deps)
147 request := createMCPRequest(map[string]any{
148 "method": "list_project_fields",
149 "owner": "octo-org",
150 "owner_type": "org",
151 "project_number": float64(1),
152 })
153 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
154
155 require.NoError(t, err)
156 require.False(t, result.IsError)
157
158 textContent := getTextResult(t, result)
159 var response map[string]any
160 err = json.Unmarshal([]byte(textContent.Text), &response)
161 require.NoError(t, err)
162 fieldsList, ok := response["fields"].([]any)
163 require.True(t, ok)
164 assert.Equal(t, 1, len(fieldsList))
165 })
166
167 t.Run("missing project_number", func(t *testing.T) {
168 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{})
169 client := mustNewGHClient(t, mockedClient)
170 deps := BaseDeps{
171 Client: client,
172 }
173 handler := toolDef.Handler(deps)
174 request := createMCPRequest(map[string]any{
175 "method": "list_project_fields",
176 "owner": "octo-org",
177 "owner_type": "org",
178 })
179 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
180
181 require.NoError(t, err)
182 require.True(t, result.IsError)
183 textContent := getTextResult(t, result)
184 assert.Contains(t, textContent.Text, "missing required parameter: project_number")
185 })
186}
187
188func verbosePullRequestProjectItemFixture() map[string]any {
189 return map[string]any{

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