@@ -2212,7 +2212,47 @@ func TestClientSideEncryptionProse(t *testing.T) {
2212
2212
2213
2213
precision := int32 (2 )
2214
2214
2215
+ d128_0 , err := primitive .ParseDecimal128 ("0" )
2216
+ assert .Nil (mt , err )
2217
+ d128_6 , err := primitive .ParseDecimal128 ("6" )
2218
+ assert .Nil (mt , err )
2219
+ d128_30 , err := primitive .ParseDecimal128 ("30" )
2220
+ assert .Nil (mt , err )
2221
+ d128_200 , err := primitive .ParseDecimal128 ("200" )
2222
+ assert .Nil (mt , err )
2223
+ d128_201 , err := primitive .ParseDecimal128 ("201" )
2224
+ assert .Nil (mt , err )
2225
+
2215
2226
tests := []testcase {
2227
+ {
2228
+ typeStr : "DecimalNoPrecision" ,
2229
+ field : "encryptedDecimalNoPrecision" ,
2230
+ typeBson : bson .TypeDecimal128 ,
2231
+ rangeOpts : options.RangeOptions {
2232
+ Sparsity : 1 ,
2233
+ },
2234
+ zero : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_0 )},
2235
+ six : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_6 )},
2236
+ thirty : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_30 )},
2237
+ twoHundred : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_200 )},
2238
+ twoHundredOne : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_201 )},
2239
+ },
2240
+ {
2241
+ typeStr : "DecimalPrecision" ,
2242
+ field : "encryptedDecimalPrecision" ,
2243
+ typeBson : bson .TypeDecimal128 ,
2244
+ rangeOpts : options.RangeOptions {
2245
+ Min : & bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_0 )},
2246
+ Max : & bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_200 )},
2247
+ Sparsity : 1 ,
2248
+ Precision : & precision ,
2249
+ },
2250
+ zero : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_0 )},
2251
+ six : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_6 )},
2252
+ thirty : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_30 )},
2253
+ twoHundred : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_200 )},
2254
+ twoHundredOne : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_201 )},
2255
+ },
2216
2256
{
2217
2257
typeStr : "DoubleNoPrecision" ,
2218
2258
field : "encryptedDoubleNoPrecision" ,
@@ -2291,6 +2331,10 @@ func TestClientSideEncryptionProse(t *testing.T) {
2291
2331
2292
2332
for _ , test := range tests {
2293
2333
mt .Run (test .typeStr , func (mt * mtest.T ) {
2334
+ if test .typeStr == "DecimalNoPrecision" && mtest .ClusterTopologyKind () != mtest .ReplicaSet {
2335
+ mt .Skipf ("Skipping DecimalNoPrecision tests on a non ReplicaSet topology. DecimalNoPrecision queries are expected to take a long time and may exceed the default mongos timeout" )
2336
+ }
2337
+
2294
2338
// Test Setup ... begin
2295
2339
encryptedFields := readJSONFile (mt , fmt .Sprintf ("range-encryptedFields-%v.json" , test .typeStr ))
2296
2340
key1Document := readJSONFile (mt , "key1-document.json" )
@@ -2548,7 +2592,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
2548
2592
checkCursorResults (cursor , test .field , test .zero , test .six )
2549
2593
})
2550
2594
2551
- if test .field != "encryptedDoubleNoPrecision" {
2595
+ if test .field != "encryptedDoubleNoPrecision" && test . field != "encryptedDecimalNoPrecision" {
2552
2596
mt .Run ("Case 6: encrypting a document greater than the maximum errors" , func (mt * mtest.T ) {
2553
2597
encryptedClient , clientEncryption := testSetup ()
2554
2598
defer clientEncryption .Close (context .Background ())
@@ -2585,7 +2629,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
2585
2629
})
2586
2630
}
2587
2631
2588
- if test .field != "encryptedDoubleNoPrecision" && test .field != "encryptedDoublePrecision" {
2632
+ if test .field != "encryptedDoubleNoPrecision" && test .field != "encryptedDoublePrecision" && test . field != "encryptedDecimalNoPrecision" && test . field != "encryptedDecimalPrecision" {
2589
2633
mt .Run ("Case 8: setting precision errors if the type is not a double" , func (mt * mtest.T ) {
2590
2634
encryptedClient , clientEncryption := testSetup ()
2591
2635
defer clientEncryption .Close (context .Background ())
0 commit comments