Skip to content

Commit

Permalink
GODRIVER-2701 PR Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
timothy-kim-mongo committed Jul 16, 2024
1 parent 95f571f commit 90a7719
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions mongo/integration/index_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,31 +618,31 @@ func TestIndexView(t *testing.T) {
name: "custom index name and unique indexes",
models: []mongo.IndexModel{
{
Keys: bson.D{{"username", 1}},
Keys: bson.D{{"username", int32(1)}},
Options: options.Index().SetUnique(true).SetName("myidx"),
},
},
index: bson.D{{"username", 1}},
index: bson.D{{"username", int32(1)}},
want: "myidx",
},
{
name: "normal generated index name",
models: []mongo.IndexModel{
{
Keys: bson.D{{"foo", -1}},
Keys: bson.D{{"foo", int32(-1)}},
},
},
index: bson.D{{"foo", -1}},
index: bson.D{{"foo", int32(-1)}},
want: "foo_-1",
},
{
name: "compound index",
models: []mongo.IndexModel{
{
Keys: bson.D{{"foo", 1}, {"bar", 1}},
Keys: bson.D{{"foo", int32(1)}, {"bar", int32(1)}},
},
},
index: bson.D{{"foo", 1}, {"bar", 1}},
index: bson.D{{"foo", int32(1)}, {"bar", int32(1)}},
want: "foo_1_bar_1",
},
{
Expand All @@ -653,7 +653,7 @@ func TestIndexView(t *testing.T) {
},
},
// Key is automatically set to Full Text Search for any text index
index: bson.D{{"_fts", "text"}, {"_ftsx", 1}},
index: bson.D{{"_fts", "text"}, {"_ftsx", int32(1)}},
want: "plot1_text_plot2_text",
},
}
Expand All @@ -663,6 +663,14 @@ func TestIndexView(t *testing.T) {
iv := mt.Coll.Indexes()
indexNames, err := iv.CreateMany(context.Background(), test.models)

s, _ := test.index.(bson.D)
for _, name := range indexNames {
verifyIndexExists(mt, iv, index{
Key: s,
Name: name,
})
}

assert.NoError(mt, err)
assert.Equal(mt, len(test.models), len(indexNames), "expected %v index names, got %v", len(test.models), len(indexNames))

Expand Down

0 comments on commit 90a7719

Please sign in to comment.