From 93e1a1e331c3f2d385e244044b73b5a39f9d6483 Mon Sep 17 00:00:00 2001 From: Benjamin Rewis Date: Tue, 19 Jan 2021 11:45:26 -0800 Subject: [PATCH] GODRIVER-1794 Update index_view_test to avoid mtest.ServerVersion() --- mongo/integration/index_view_test.go | 37 ++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/mongo/integration/index_view_test.go b/mongo/integration/index_view_test.go index 3a8950058f..b93da1755b 100644 --- a/mongo/integration/index_view_test.go +++ b/mongo/integration/index_view_test.go @@ -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). @@ -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"}},