MCPcopy Create free account
hub / github.com/cli/cli / TestSearcherIssuesAdvancedSyntax

Function TestSearcherIssuesAdvancedSyntax

pkg/search/searcher_test.go:1140–1220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

VerifyMethod · 0.95
RegisterMethod · 0.95
IssuesMethod · 0.95
QueryMatcherFunction · 0.92
JSONResponseFunction · 0.92
NewSearcherFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected