(t *testing.T)
| 1137 | } |
| 1138 | |
| 1139 | func TestSearcherIssuesAdvancedSyntax(t *testing.T) { |
| 1140 | query := Query{ |
| 1141 | Kind: KindIssues, |
| 1142 | Limit: 1, |
| 1143 | Keywords: []string{"keyword"}, |
| 1144 | Qualifiers: Qualifiers{ |
| 1145 | // Ordinary qualifiers |
| 1146 | Author: "johndoe", |
| 1147 | Label: []string{"foo", "bar"}, |
| 1148 | // Special qualifiers (that should be grouped and OR-ed when using advanced issue search) |
| 1149 | Repo: []string{"foo/bar", "foo/baz"}, |
| 1150 | Is: []string{"private", "public"}, |
| 1151 | User: []string{"johndoe", "janedoe"}, |
| 1152 | In: []string{"title", "body", "comments"}, |
| 1153 | }, |
| 1154 | } |
| 1155 | |
| 1156 | tests := []struct { |
| 1157 | name string |
| 1158 | query Query |
| 1159 | detector fd.Detector |
| 1160 | wantValues url.Values |
| 1161 | wantErr string |
| 1162 | }{ |
| 1163 | { |
| 1164 | // TODO advancedIssueSearchCleanup |
| 1165 | // Remove this test case once GHES 3.17 support ends. |
| 1166 | name: "advanced issue search not supported", |
| 1167 | detector: fd.AdvancedIssueSearchUnsupported(), |
| 1168 | query: query, |
| 1169 | wantValues: url.Values{ |
| 1170 | "q": []string{"keyword author:johndoe in:body in:comments in:title is:private is:public label:bar label:foo repo:foo/bar repo:foo/baz user:janedoe user:johndoe"}, |
| 1171 | "advanced_search": nil, // assert absence |
| 1172 | }, |
| 1173 | }, |
| 1174 | { |
| 1175 | // TODO advancedIssueSearchCleanup |
| 1176 | // Remove this test case once GHES 3.17 support ends. |
| 1177 | name: "advanced issue search supported as an opt-in feature", |
| 1178 | detector: fd.AdvancedIssueSearchSupportedAsOptIn(), |
| 1179 | query: query, |
| 1180 | wantValues: url.Values{ |
| 1181 | "q": []string{"( keyword ) author:johndoe (in:body OR in:comments OR in:title) (is:private OR is:public) label:bar label:foo (repo:foo/bar OR repo:foo/baz) (user:janedoe OR user:johndoe)"}, |
| 1182 | "advanced_search": []string{"true"}, // opt-in |
| 1183 | }, |
| 1184 | }, |
| 1185 | { |
| 1186 | // TODO advancedIssueSearchCleanup |
| 1187 | // No need for feature detection once GHES 3.17 support ends. |
| 1188 | name: "advanced issue search supported as the only search backend", |
| 1189 | detector: fd.AdvancedIssueSearchSupportedAsOnlyBackend(), |
| 1190 | query: query, |
| 1191 | wantValues: url.Values{ |
| 1192 | "q": []string{"( keyword ) author:johndoe (in:body OR in:comments OR in:title) (is:private OR is:public) label:bar label:foo (repo:foo/bar OR repo:foo/baz) (user:janedoe OR user:johndoe)"}, |
| 1193 | "advanced_search": nil, // assert absence |
| 1194 | }, |
| 1195 | }, |
| 1196 | } |
nothing calls this directly
no test coverage detected