(t *testing.T)
| 279 | } |
| 280 | |
| 281 | func Test_SearchRepositories_FullOutput(t *testing.T) { |
| 282 | mockSearchResult := &github.RepositoriesSearchResult{ |
| 283 | Total: github.Ptr(1), |
| 284 | IncompleteResults: github.Ptr(false), |
| 285 | Repositories: []*github.Repository{ |
| 286 | { |
| 287 | ID: github.Ptr(int64(12345)), |
| 288 | Name: github.Ptr("test-repo"), |
| 289 | FullName: github.Ptr("owner/test-repo"), |
| 290 | HTMLURL: github.Ptr("https://github.com/owner/test-repo"), |
| 291 | Description: github.Ptr("Test repository"), |
| 292 | StargazersCount: github.Ptr(100), |
| 293 | }, |
| 294 | }, |
| 295 | } |
| 296 | |
| 297 | mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 298 | GetSearchRepositories: expectQueryParams(t, map[string]string{ |
| 299 | "q": "golang test", |
| 300 | "page": "1", |
| 301 | "per_page": "30", |
| 302 | }).andThen( |
| 303 | mockResponse(t, http.StatusOK, mockSearchResult), |
| 304 | ), |
| 305 | }) |
| 306 | |
| 307 | client := mustNewGHClient(t, mockedClient) |
| 308 | serverTool := SearchRepositories(translations.NullTranslationHelper) |
| 309 | deps := BaseDeps{ |
| 310 | Client: client, |
| 311 | } |
| 312 | handler := serverTool.Handler(deps) |
| 313 | |
| 314 | args := map[string]any{ |
| 315 | "query": "golang test", |
| 316 | "minimal_output": false, |
| 317 | } |
| 318 | |
| 319 | request := createMCPRequest(args) |
| 320 | |
| 321 | result, err := handler(ContextWithDeps(context.Background(), deps), &request) |
| 322 | |
| 323 | require.NoError(t, err) |
| 324 | require.False(t, result.IsError) |
| 325 | |
| 326 | textContent := getTextResult(t, result) |
| 327 | |
| 328 | // Unmarshal as full GitHub API response |
| 329 | var returnedResult github.RepositoriesSearchResult |
| 330 | err = json.Unmarshal([]byte(textContent.Text), &returnedResult) |
| 331 | require.NoError(t, err) |
| 332 | |
| 333 | // Verify it's the full API response, not minimal |
| 334 | assert.Equal(t, *mockSearchResult.Total, *returnedResult.Total) |
| 335 | assert.Equal(t, *mockSearchResult.IncompleteResults, *returnedResult.IncompleteResults) |
| 336 | assert.Len(t, returnedResult.Repositories, 1) |
| 337 | assert.Equal(t, *mockSearchResult.Repositories[0].ID, *returnedResult.Repositories[0].ID) |
| 338 | assert.Equal(t, *mockSearchResult.Repositories[0].Name, *returnedResult.Repositories[0].Name) |
nothing calls this directly
no test coverage detected