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

Function TestSearcherIssuesSemanticSearch

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

Source from the content-addressed store, hash-verified

1220}
1221
1222func TestSearcherIssuesSemanticSearch(t *testing.T) {
1223 tests := []struct {
1224 name string
1225 searchType string
1226 detector fd.Detector
1227 wantValues url.Values
1228 wantErr string
1229 }{
1230 {
1231 name: "semantic search sends search_type=semantic",
1232 searchType: "semantic",
1233 detector: fd.SemanticSearchSupported(),
1234 wantValues: url.Values{"search_type": []string{"semantic"}},
1235 },
1236 {
1237 name: "hybrid search sends search_type=hybrid",
1238 searchType: "hybrid",
1239 detector: fd.SemanticSearchSupported(),
1240 wantValues: url.Values{"search_type": []string{"hybrid"}},
1241 },
1242 {
1243 name: "lexical search sends no search_type param",
1244 searchType: "",
1245 detector: fd.SemanticSearchSupported(),
1246 wantValues: url.Values{"search_type": nil}, // assert absence
1247 },
1248 {
1249 name: "semantic search not supported on host",
1250 searchType: "semantic",
1251 detector: fd.SemanticSearchUnsupported(),
1252 wantErr: "semantic search is not supported on this host: github.com",
1253 },
1254 {
1255 name: "hybrid search not supported on host",
1256 searchType: "hybrid",
1257 detector: fd.SemanticSearchUnsupported(),
1258 wantErr: "hybrid search is not supported on this host: github.com",
1259 },
1260 }
1261
1262 for _, tt := range tests {
1263 t.Run(tt.name, func(t *testing.T) {
1264 reg := &httpmock.Registry{}
1265 defer reg.Verify(t)
1266
1267 if tt.wantErr == "" {
1268 reg.Register(
1269 httpmock.QueryMatcher("GET", "search/issues", tt.wantValues),
1270 httpmock.JSONResponse(IssuesResult{}),
1271 )
1272 }
1273
1274 query := Query{
1275 Kind: KindIssues,
1276 Limit: 30,
1277 Keywords: []string{"keyword"},
1278 IssueSearchType: tt.searchType,
1279 }

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