@@ -71,31 +71,36 @@ func TestIndexView(t *testing.T) {
71
71
})
72
72
})
73
73
mt .Run ("all options" , func (mt * mtest.T ) {
74
+ opts := options .Index ().
75
+ SetBackground (false ).
76
+ SetExpireAfterSeconds (10 ).
77
+ SetName ("a" ).
78
+ SetSparse (false ).
79
+ SetUnique (false ).
80
+ SetVersion (1 ).
81
+ SetDefaultLanguage ("english" ).
82
+ SetLanguageOverride ("english" ).
83
+ SetTextVersion (1 ).
84
+ SetWeights (bson.D {}).
85
+ SetSphereVersion (1 ).
86
+ SetBits (2 ).
87
+ SetMax (10 ).
88
+ SetMin (1 ).
89
+ SetPartialFilterExpression (bson.D {}).
90
+ SetStorageEngine (bson.D {
91
+ {"wiredTiger" , bson.D {
92
+ {"configString" , "block_compressor=zlib" },
93
+ }},
94
+ })
95
+
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
+ }
74
100
// Omits collation option because it's incompatible with version option
75
101
_ , err := mt .Coll .Indexes ().CreateOne (mtest .Background , mongo.IndexModel {
76
- Keys : bson.D {{"foo" , "text" }},
77
- Options : options .Index ().
78
- SetBackground (false ).
79
- SetExpireAfterSeconds (10 ).
80
- SetName ("a" ).
81
- SetSparse (false ).
82
- SetUnique (false ).
83
- SetVersion (1 ).
84
- SetDefaultLanguage ("english" ).
85
- SetLanguageOverride ("english" ).
86
- SetTextVersion (1 ).
87
- SetWeights (bson.D {}).
88
- SetSphereVersion (1 ).
89
- SetBits (2 ).
90
- SetMax (10 ).
91
- SetMin (1 ).
92
- SetBucketSize (1 ).
93
- SetPartialFilterExpression (bson.D {}).
94
- SetStorageEngine (bson.D {
95
- {"wiredTiger" , bson.D {
96
- {"configString" , "block_compressor=zlib" },
97
- }},
98
- }),
102
+ Keys : bson.D {{"foo" , "text" }},
103
+ Options : opts ,
99
104
})
100
105
assert .Nil (mt , err , "CreateOne error: %v" , err )
101
106
})
0 commit comments