Skip to content

Commit 5e239f1

Browse files
committed
Split off ElasticSearch-specific test scenarios
1 parent 4f6d920 commit 5e239f1

File tree

1 file changed

+41
-29
lines changed

1 file changed

+41
-29
lines changed

modules/indexer/code/indexer_test.go

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -165,35 +165,6 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
165165
},
166166
},
167167
},
168-
// Search for matches on the contents of files within the repo '62'.
169-
// This scenario yields two results (both are based on contents, the first one is an exact match where as the second is a 'fuzzy' one)
170-
{
171-
RepoIDs: []int64{62},
172-
Keyword: "This is not cheese",
173-
Langs: 1,
174-
Results: []codeSearchResult{
175-
{
176-
Filename: "potato/ham.md",
177-
Content: "This is not cheese",
178-
},
179-
{
180-
Filename: "ham.md",
181-
Content: "This is also not cheese",
182-
},
183-
},
184-
},
185-
// Search for matches on the contents of files regardless of case.
186-
{
187-
RepoIDs: nil,
188-
Keyword: "dESCRIPTION",
189-
Langs: 1,
190-
Results: []codeSearchResult{
191-
{
192-
Filename: "README.md",
193-
Content: "# repo1\n\nDescription for repo1",
194-
},
195-
},
196-
},
197168
// Search for an exact match on the filename within the repo '62' (case insenstive).
198169
// This scenario yields a single result (the file avocado.md on the repo '62')
199170
{
@@ -233,6 +204,47 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
233204
},
234205
}
235206

207+
if name == "elastic_search" {
208+
// Additional scenarios for elastic_search only
209+
additional := []struct {
210+
RepoIDs []int64
211+
Keyword string
212+
Langs int
213+
Results []codeSearchResult
214+
}{
215+
// Search for matches on the contents of files within the repo '62'.
216+
// This scenario yields two results (both are based on contents, the first one is an exact match where as the second is a 'fuzzy' one)
217+
{
218+
RepoIDs: []int64{62},
219+
Keyword: "This is not cheese",
220+
Langs: 1,
221+
Results: []codeSearchResult{
222+
{
223+
Filename: "potato/ham.md",
224+
Content: "This is not cheese",
225+
},
226+
{
227+
Filename: "ham.md",
228+
Content: "This is also not cheese",
229+
},
230+
},
231+
},
232+
// Search for matches on the contents of files regardless of case.
233+
{
234+
RepoIDs: nil,
235+
Keyword: "dESCRIPTION",
236+
Langs: 1,
237+
Results: []codeSearchResult{
238+
{
239+
Filename: "README.md",
240+
Content: "# repo1\n\nDescription for repo1",
241+
},
242+
},
243+
},
244+
}
245+
keywords = append(keywords, additional...)
246+
}
247+
236248
for _, kw := range keywords {
237249
t.Run(kw.Keyword, func(t *testing.T) {
238250
total, res, langs, err := indexer.Search(context.TODO(), &internal.SearchOptions{

0 commit comments

Comments
 (0)