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