(t *testing.T)
| 438 | } |
| 439 | |
| 440 | func TestGetRepoSuggestions(t *testing.T) { |
| 441 | tests := []struct { |
| 442 | searchText string // The input search string |
| 443 | queryText string // The wanted query string (based off searchText) |
| 444 | sort string // (Optional) The RepoSearchParameters.Sort param |
| 445 | maxRepos string // (Optional) The RepoSearchParameters.MaxRepos param |
| 446 | }{ |
| 447 | { |
| 448 | searchText: "test", |
| 449 | queryText: "test", |
| 450 | }, |
| 451 | { |
| 452 | searchText: "org/repo", |
| 453 | queryText: "repo user:org", |
| 454 | }, |
| 455 | { |
| 456 | searchText: "org/repo/extra", |
| 457 | queryText: "repo/extra user:org", |
| 458 | }, |
| 459 | { |
| 460 | searchText: "test", |
| 461 | queryText: "test", |
| 462 | sort: "stars", |
| 463 | maxRepos: "1000", |
| 464 | }, |
| 465 | } |
| 466 | |
| 467 | for _, tt := range tests { |
| 468 | runRepoSearchTest(t, tt.searchText, tt.queryText, tt.sort, tt.maxRepos) |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | func createFakeSearchReposServer(t *testing.T, wantSearchText string, wantSort string, wantPerPage string, responseRepos []*Repository) *httptest.Server { |
| 473 | return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected