(t *testing.T)
| 852 | } |
| 853 | |
| 854 | func TestSearcherIssues(t *testing.T) { |
| 855 | query := Query{ |
| 856 | Keywords: []string{"keyword"}, |
| 857 | Kind: "issues", |
| 858 | Limit: 30, |
| 859 | Order: "desc", |
| 860 | Sort: "comments", |
| 861 | Qualifiers: Qualifiers{ |
| 862 | Language: "go", |
| 863 | Is: []string{"public", "locked"}, |
| 864 | }, |
| 865 | } |
| 866 | |
| 867 | values := url.Values{ |
| 868 | "page": []string{"1"}, |
| 869 | "per_page": []string{"30"}, |
| 870 | "order": []string{"desc"}, |
| 871 | "sort": []string{"comments"}, |
| 872 | "q": []string{"keyword is:locked is:public language:go"}, |
| 873 | } |
| 874 | |
| 875 | tests := []struct { |
| 876 | name string |
| 877 | host string |
| 878 | query Query |
| 879 | result IssuesResult |
| 880 | wantErr bool |
| 881 | errMsg string |
| 882 | httpStubs func(*httpmock.Registry) |
| 883 | }{ |
| 884 | { |
| 885 | name: "searches issues", |
| 886 | query: query, |
| 887 | result: IssuesResult{ |
| 888 | IncompleteResults: false, |
| 889 | Items: []Issue{{Number: 1234}}, |
| 890 | Total: 1, |
| 891 | }, |
| 892 | httpStubs: func(reg *httpmock.Registry) { |
| 893 | reg.Register( |
| 894 | httpmock.QueryMatcher("GET", "search/issues", values), |
| 895 | httpmock.JSONResponse(map[string]any{ |
| 896 | "incomplete_results": false, |
| 897 | "total_count": 1, |
| 898 | "items": []any{ |
| 899 | map[string]any{ |
| 900 | "number": 1234, |
| 901 | }, |
| 902 | }, |
| 903 | }), |
| 904 | ) |
| 905 | }, |
| 906 | }, |
| 907 | { |
| 908 | name: "searches issues for enterprise host", |
| 909 | host: "enterprise.com", |
| 910 | query: query, |
| 911 | result: IssuesResult{ |
nothing calls this directly
no test coverage detected