MCPcopy
hub / github.com/cli/cli / TestSearcherIssuesAdvancedSyntax

Function TestSearcherIssuesAdvancedSyntax

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

Source from the content-addressed store, hash-verified

1137}
1138
1139func 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 }

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