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