(t *testing.T)
| 510 | } |
| 511 | |
| 512 | func Test_SearchUsers(t *testing.T) { |
| 513 | // Verify tool definition once |
| 514 | serverTool := SearchUsers(translations.NullTranslationHelper) |
| 515 | tool := serverTool.Tool |
| 516 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 517 | |
| 518 | assert.Equal(t, "search_users", tool.Name) |
| 519 | assert.NotEmpty(t, tool.Description) |
| 520 | |
| 521 | schema, ok := tool.InputSchema.(*jsonschema.Schema) |
| 522 | require.True(t, ok, "InputSchema should be *jsonschema.Schema") |
| 523 | assert.Contains(t, schema.Properties, "query") |
| 524 | assert.Contains(t, schema.Properties, "sort") |
| 525 | assert.Contains(t, schema.Properties, "order") |
| 526 | assert.Contains(t, schema.Properties, "perPage") |
| 527 | assert.Contains(t, schema.Properties, "page") |
| 528 | assert.ElementsMatch(t, schema.Required, []string{"query"}) |
| 529 | |
| 530 | // Setup mock search results |
| 531 | mockSearchResult := &github.UsersSearchResult{ |
| 532 | Total: github.Ptr(2), |
| 533 | IncompleteResults: github.Ptr(false), |
| 534 | Users: []*github.User{ |
| 535 | { |
| 536 | Login: github.Ptr("user1"), |
| 537 | ID: github.Ptr(int64(1001)), |
| 538 | HTMLURL: github.Ptr("https://github.com/user1"), |
| 539 | AvatarURL: github.Ptr("https://avatars.githubusercontent.com/u/1001"), |
| 540 | }, |
| 541 | { |
| 542 | Login: github.Ptr("user2"), |
| 543 | ID: github.Ptr(int64(1002)), |
| 544 | HTMLURL: github.Ptr("https://github.com/user2"), |
| 545 | AvatarURL: github.Ptr("https://avatars.githubusercontent.com/u/1002"), |
| 546 | Type: github.Ptr("User"), |
| 547 | }, |
| 548 | }, |
| 549 | } |
| 550 | |
| 551 | tests := []struct { |
| 552 | name string |
| 553 | mockedClient *http.Client |
| 554 | requestArgs map[string]any |
| 555 | expectError bool |
| 556 | expectedResult *github.UsersSearchResult |
| 557 | expectedErrMsg string |
| 558 | }{ |
| 559 | { |
| 560 | name: "successful users search with all parameters", |
| 561 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 562 | GetSearchUsers: expectQueryParams(t, map[string]string{ |
| 563 | "q": "type:user location:finland language:go", |
| 564 | "sort": "followers", |
| 565 | "order": "desc", |
| 566 | "page": "1", |
| 567 | "per_page": "30", |
| 568 | }).andThen( |
| 569 | mockResponse(t, http.StatusOK, mockSearchResult), |
nothing calls this directly
no test coverage detected