(t *testing.T)
| 566 | } |
| 567 | |
| 568 | func TestSearcherRepositories(t *testing.T) { |
| 569 | query := Query{ |
| 570 | Keywords: []string{"keyword"}, |
| 571 | Kind: "repositories", |
| 572 | Limit: 30, |
| 573 | Order: "desc", |
| 574 | Sort: "stars", |
| 575 | Qualifiers: Qualifiers{ |
| 576 | Stars: ">=5", |
| 577 | Topic: []string{"topic"}, |
| 578 | }, |
| 579 | } |
| 580 | |
| 581 | values := url.Values{ |
| 582 | "page": []string{"1"}, |
| 583 | "per_page": []string{"30"}, |
| 584 | "order": []string{"desc"}, |
| 585 | "sort": []string{"stars"}, |
| 586 | "q": []string{"keyword stars:>=5 topic:topic"}, |
| 587 | } |
| 588 | |
| 589 | tests := []struct { |
| 590 | name string |
| 591 | host string |
| 592 | query Query |
| 593 | result RepositoriesResult |
| 594 | wantErr bool |
| 595 | errMsg string |
| 596 | httpStubs func(*httpmock.Registry) |
| 597 | }{ |
| 598 | { |
| 599 | name: "searches repositories", |
| 600 | query: query, |
| 601 | result: RepositoriesResult{ |
| 602 | IncompleteResults: false, |
| 603 | Items: []Repository{{Name: "test"}}, |
| 604 | Total: 1, |
| 605 | }, |
| 606 | httpStubs: func(reg *httpmock.Registry) { |
| 607 | reg.Register( |
| 608 | httpmock.QueryMatcher("GET", "search/repositories", values), |
| 609 | httpmock.JSONResponse(map[string]any{ |
| 610 | "incomplete_results": false, |
| 611 | "total_count": 1, |
| 612 | "items": []any{ |
| 613 | map[string]any{ |
| 614 | "name": "test", |
| 615 | }, |
| 616 | }, |
| 617 | }), |
| 618 | ) |
| 619 | }, |
| 620 | }, |
| 621 | { |
| 622 | name: "searches repositories for enterprise host", |
| 623 | host: "enterprise.com", |
| 624 | query: query, |
| 625 | result: RepositoriesResult{ |
nothing calls this directly
no test coverage detected