Skip to content

Commit 93e1a1e

Browse files
author
Benjamin Rewis
committed
GODRIVER-1794 Update index_view_test to avoid mtest.ServerVersion()
1 parent 07e49da commit 93e1a1e

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

mongo/integration/index_view_test.go

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestIndexView(t *testing.T) {
7070
Name: indexName,
7171
})
7272
})
73-
mt.Run("all options", func(mt *mtest.T) {
73+
mt.RunOpts("all options", mtest.NewOptions().MinServerVersion("4.9"), func(mt *mtest.T) {
7474
opts := options.Index().
7575
SetBackground(false).
7676
SetExpireAfterSeconds(10).
@@ -93,10 +93,37 @@ func TestIndexView(t *testing.T) {
9393
}},
9494
})
9595

96-
// Only check SetBucketSize if version is less than 4.9
97-
if mtest.CompareServerVersions(mtest.ServerVersion(), "4.9") < 0 {
98-
opts.SetBucketSize(1)
99-
}
96+
// Omits collation option because it's incompatible with version option
97+
_, err := mt.Coll.Indexes().CreateOne(mtest.Background, mongo.IndexModel{
98+
Keys: bson.D{{"foo", "text"}},
99+
Options: opts,
100+
})
101+
assert.Nil(mt, err, "CreateOne error: %v", err)
102+
})
103+
mt.RunOpts("all options including bucketSize", mtest.NewOptions().MaxServerVersion("4.8"), func(mt *mtest.T) {
104+
opts := options.Index().
105+
SetBackground(false).
106+
SetExpireAfterSeconds(10).
107+
SetName("a").
108+
SetSparse(false).
109+
SetUnique(false).
110+
SetVersion(1).
111+
SetDefaultLanguage("english").
112+
SetLanguageOverride("english").
113+
SetTextVersion(1).
114+
SetWeights(bson.D{}).
115+
SetSphereVersion(1).
116+
SetBits(2).
117+
SetMax(10).
118+
SetMin(1).
119+
SetPartialFilterExpression(bson.D{}).
120+
SetStorageEngine(bson.D{
121+
{"wiredTiger", bson.D{
122+
{"configString", "block_compressor=zlib"},
123+
}},
124+
}).
125+
SetBucketSize(1)
126+
100127
// Omits collation option because it's incompatible with version option
101128
_, err := mt.Coll.Indexes().CreateOne(mtest.Background, mongo.IndexModel{
102129
Keys: bson.D{{"foo", "text"}},

0 commit comments

Comments
 (0)