@ -165,73 +165,85 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
} ,
} ,
} ,
} ,
} ,
} ,
// Search for matches on the contents of files within the repo '62' .
// Search for an exact match on the filename within the repo '62' (case insenstive) .
// 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 )
// This scenario yields a single result (the file avocado.md on the repo '62' )
{
{
RepoIDs : [ ] int64 { 62 } ,
RepoIDs : [ ] int64 { 62 } ,
Keyword : " This is not cheese ",
Keyword : " AVOCADO.MD ",
Langs : 1 ,
Langs : 1 ,
Results : [ ] codeSearchResult {
Results : [ ] codeSearchResult {
{
{
Filename : "potato/ham.md" ,
Filename : "avocado.md" ,
Content : "This is not cheese" ,
Content : "# repo1\n\npineaple pie of cucumber juice" ,
} ,
{
Filename : "ham.md" ,
Content : "This is also not cheese" ,
} ,
} ,
} ,
} ,
} ,
} ,
// Search for matches on the contents of files regardless of case .
// Search for matches on the contents of files when the criteria is a expression.
{
{
RepoIDs : nil ,
RepoIDs : [ ] int64 { 62 } ,
Keyword : " dESCRIPTION ",
Keyword : " console.log ",
Langs : 1 ,
Langs : 1 ,
Results : [ ] codeSearchResult {
Results : [ ] codeSearchResult {
{
{
Filename : " README.md ",
Filename : " example-file.js ",
Content : " # repo1\n\nDescription for repo1 ",
Content : " console.log(\"Hello, World!\") ",
} ,
} ,
} ,
} ,
} ,
} ,
// Search for an exact match on the filename within the repo '62' (case insenstive).
// Search for matches on the contents of files when the criteria is part of a expression.
// This scenario yields a single result (the file avocado.md on the repo '62')
{
{
RepoIDs : [ ] int64 { 62 } ,
RepoIDs : [ ] int64 { 62 } ,
Keyword : " AVOCADO.MD ",
Keyword : " log ",
Langs : 1 ,
Langs : 1 ,
Results : [ ] codeSearchResult {
Results : [ ] codeSearchResult {
{
{
Filename : " avocado.md ",
Filename : " example-file.js ",
Content : " # repo1\n\npineaple pie of cucumber juice ",
Content : " console.log(\"Hello, World!\") ",
} ,
} ,
} ,
} ,
} ,
} ,
// Search for matches on the contents of files when the criteria is a expression.
}
if name == "elastic_search" {
// Additional scenarios for elastic_search only
additional := [ ] struct {
RepoIDs [ ] int64
Keyword string
Langs int
Results [ ] codeSearchResult
} {
// Search for matches on the contents of files within the repo '62'.
// 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)
{
{
RepoIDs : [ ] int64 { 62 } ,
RepoIDs : [ ] int64 { 62 } ,
Keyword : "console.log" ,
Keyword : "This is not cheese ",
Langs : 1 ,
Langs : 1 ,
Results : [ ] codeSearchResult {
Results : [ ] codeSearchResult {
{
{
Filename : "example-file.js" ,
Filename : "potato/ham.md" ,
Content : "console.log(\"Hello, World!\")" ,
Content : "This is not cheese" ,
} ,
{
Filename : "ham.md" ,
Content : "This is also not cheese" ,
} ,
} ,
} ,
} ,
} ,
} ,
// Search for matches on the contents of files when the criteria is part of a expression.
// Search for matches on the contents of files regardless of case .
{
{
RepoIDs : [ ] int64 { 62 } ,
RepoIDs : nil ,
Keyword : "log ",
Keyword : "dESCRIPTION ",
Langs : 1 ,
Langs : 1 ,
Results : [ ] codeSearchResult {
Results : [ ] codeSearchResult {
{
{
Filename : "example-file.js ",
Filename : "README.md ",
Content : "console.log(\"Hello, World!\") ",
Content : "# repo1\n\nDescription for repo1 ",
} ,
} ,
} ,
} ,
} ,
} ,
}
}
keywords = append ( keywords , additional ... )
}
for _ , kw := range keywords {
for _ , kw := range keywords {
t . Run ( kw . Keyword , func ( t * testing . T ) {
t . Run ( kw . Keyword , func ( t * testing . T ) {