(t *testing.T)
| 339 | } |
| 340 | |
| 341 | func Test_SearchCode(t *testing.T) { |
| 342 | // Verify tool definition once |
| 343 | serverTool := SearchCode(translations.NullTranslationHelper) |
| 344 | tool := serverTool.Tool |
| 345 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 346 | |
| 347 | assert.Equal(t, "search_code", tool.Name) |
| 348 | assert.NotEmpty(t, tool.Description) |
| 349 | |
| 350 | schema, ok := tool.InputSchema.(*jsonschema.Schema) |
| 351 | require.True(t, ok, "InputSchema should be *jsonschema.Schema") |
| 352 | assert.Contains(t, schema.Properties, "query") |
| 353 | assert.Contains(t, schema.Properties, "sort") |
| 354 | assert.Contains(t, schema.Properties, "order") |
| 355 | assert.Contains(t, schema.Properties, "perPage") |
| 356 | assert.Contains(t, schema.Properties, "page") |
| 357 | assert.ElementsMatch(t, schema.Required, []string{"query"}) |
| 358 | |
| 359 | // Setup mock search results |
| 360 | mockSearchResult := &github.CodeSearchResult{ |
| 361 | Total: github.Ptr(2), |
| 362 | IncompleteResults: github.Ptr(false), |
| 363 | CodeResults: []*github.CodeResult{ |
| 364 | { |
| 365 | Name: github.Ptr("file1.go"), |
| 366 | Path: github.Ptr("path/to/file1.go"), |
| 367 | SHA: github.Ptr("abc123def456"), |
| 368 | Repository: &github.Repository{ |
| 369 | Name: github.Ptr("repo"), |
| 370 | FullName: github.Ptr("owner/repo"), |
| 371 | }, |
| 372 | TextMatches: []*github.TextMatch{ |
| 373 | { |
| 374 | Fragment: github.Ptr("func main() { fmt.Println(\"hello\") }"), |
| 375 | }, |
| 376 | }, |
| 377 | }, |
| 378 | { |
| 379 | Name: github.Ptr("file2.go"), |
| 380 | Path: github.Ptr("path/to/file2.go"), |
| 381 | SHA: github.Ptr("def456abc123"), |
| 382 | Repository: &github.Repository{ |
| 383 | Name: github.Ptr("repo"), |
| 384 | FullName: github.Ptr("owner/repo"), |
| 385 | }, |
| 386 | }, |
| 387 | }, |
| 388 | } |
| 389 | |
| 390 | textMatchAcceptHeader := map[string]string{ |
| 391 | "Accept": "text-match", |
| 392 | } |
| 393 | |
| 394 | tests := []struct { |
| 395 | name string |
| 396 | mockedClient *http.Client |
| 397 | requestArgs map[string]any |
| 398 | expectError bool |
nothing calls this directly
no test coverage detected