Skip to content

Commit

Permalink
GODRIVER-1794 Update index_view_test to avoid mtest.ServerVersion()
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Rewis committed Jan 19, 2021
1 parent 07e49da commit 93e1a1e
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions mongo/integration/index_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestIndexView(t *testing.T) {
Name: indexName,
})
})
mt.Run("all options", func(mt *mtest.T) {
mt.RunOpts("all options", mtest.NewOptions().MinServerVersion("4.9"), func(mt *mtest.T) {
opts := options.Index().
SetBackground(false).
SetExpireAfterSeconds(10).
Expand All @@ -93,10 +93,37 @@ func TestIndexView(t *testing.T) {
}},
})

// Only check SetBucketSize if version is less than 4.9
if mtest.CompareServerVersions(mtest.ServerVersion(), "4.9") < 0 {
opts.SetBucketSize(1)
}
// Omits collation option because it's incompatible with version option
_, err := mt.Coll.Indexes().CreateOne(mtest.Background, mongo.IndexModel{
Keys: bson.D{{"foo", "text"}},
Options: opts,
})
assert.Nil(mt, err, "CreateOne error: %v", err)
})
mt.RunOpts("all options including bucketSize", mtest.NewOptions().MaxServerVersion("4.8"), func(mt *mtest.T) {
opts := options.Index().
SetBackground(false).
SetExpireAfterSeconds(10).
SetName("a").
SetSparse(false).
SetUnique(false).
SetVersion(1).
SetDefaultLanguage("english").
SetLanguageOverride("english").
SetTextVersion(1).
SetWeights(bson.D{}).
SetSphereVersion(1).
SetBits(2).
SetMax(10).
SetMin(1).
SetPartialFilterExpression(bson.D{}).
SetStorageEngine(bson.D{
{"wiredTiger", bson.D{
{"configString", "block_compressor=zlib"},
}},
}).
SetBucketSize(1)

// Omits collation option because it's incompatible with version option
_, err := mt.Coll.Indexes().CreateOne(mtest.Background, mongo.IndexModel{
Keys: bson.D{{"foo", "text"}},
Expand Down

0 comments on commit 93e1a1e

Please sign in to comment.