Skip to content

Commit d3ab891

Browse files
committed
update prose test
1 parent 1373cf2 commit d3ab891

File tree

3 files changed

+40
-63
lines changed

3 files changed

+40
-63
lines changed

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ tasks:
160160

161161
evg-test-search-index:
162162
# Use the long timeout to wait for the responses from the server.
163-
- go test ./internal/integration -run TestSearchIndex -v -timeout {{.LONG_TEST_TIMEOUT}}s >> test.suite
163+
- go test ./internal/integration -run ^TestSearchIndexProse$ -v -timeout {{.LONG_TEST_TIMEOUT}}s >> test.suite
164164

165165
evg-test-ocsp:
166166
- go test -v ./mongo -run TestOCSP ${OCSP_TLS_SHOULD_SUCCEED} >> test.suite

internal/integration/search_index_prose_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,43 @@ func TestSearchIndexProse(t *testing.T) {
472472
})
473473
assert.ErrorContains(mt, err, "Attribute mappings missing")
474474
})
475+
476+
mt.Run("case 9: Drivers use server default for unspecified name (`default`) and type (`search`)", func(mt *mtest.T) {
477+
ctx := context.Background()
478+
479+
view := mt.Coll.SearchIndexes()
480+
definition := bson.D{
481+
{"mappings", bson.D{
482+
{"dynamic", true},
483+
}},
484+
}
485+
opts := options.SearchIndexes()
486+
487+
indexName, err := view.CreateOne(ctx, mongo.SearchIndexModel{
488+
Definition: definition,
489+
Options: opts,
490+
})
491+
require.NoError(mt, err, "failed to create index")
492+
require.Equal(t, "default", indexName)
493+
494+
var doc bson.Raw
495+
for doc == nil {
496+
cursor, err := view.List(ctx, opts)
497+
require.NoError(mt, err, "failed to list")
498+
499+
if !cursor.Next(ctx) {
500+
break
501+
}
502+
name := cursor.Current.Lookup("name").StringValue()
503+
queryable := cursor.Current.Lookup("queryable").Boolean()
504+
indexType := cursor.Current.Lookup("type").StringValue()
505+
if name == indexName && queryable {
506+
doc = cursor.Current
507+
assert.Equal(mt, indexType, "search")
508+
} else {
509+
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
510+
time.Sleep(5 * time.Second)
511+
}
512+
}
513+
})
475514
}

internal/integration/search_index_test.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)