@@ -308,7 +308,9 @@ func TestCollection(t *testing.T) {
308
308
assert .Nil (mt , err , "DeleteOne error: %v" , err )
309
309
assert .Equal (mt , int64 (0 ), res .DeletedCount , "expected DeletedCount 0, got %v" , res .DeletedCount )
310
310
})
311
- mt .Run ("write error" , func (mt * mtest.T ) {
311
+ mt .RunOpts ("write error" , mtest .NewOptions ().MaxServerVersion ("5.2" ), func (mt * mtest.T ) {
312
+ // Deletes are not allowed on capped collections on MongoDB 5.2-. We use this
313
+ // behavior to test the processing of write errors.
312
314
cappedOpts := bson.D {{"capped" , true }, {"size" , 64 * 1024 }}
313
315
capped := mt .CreateCollection (mtest.Collection {
314
316
Name : "deleteOne_capped" ,
@@ -375,7 +377,9 @@ func TestCollection(t *testing.T) {
375
377
assert .Nil (mt , err , "DeleteMany error: %v" , err )
376
378
assert .Equal (mt , int64 (0 ), res .DeletedCount , "expected DeletedCount 0, got %v" , res .DeletedCount )
377
379
})
378
- mt .Run ("write error" , func (mt * mtest.T ) {
380
+ mt .RunOpts ("write error" , mtest .NewOptions ().MaxServerVersion ("5.2" ), func (mt * mtest.T ) {
381
+ // Deletes are not allowed on capped collections on MongoDB 5.2-. We use this
382
+ // behavior to test the processing of write errors.
379
383
cappedOpts := bson.D {{"capped" , true }, {"size" , 64 * 1024 }}
380
384
capped := mt .CreateCollection (mtest.Collection {
381
385
Name : "deleteMany_capped" ,
@@ -1501,7 +1505,9 @@ func TestCollection(t *testing.T) {
1501
1505
})
1502
1506
}
1503
1507
})
1504
- mt .Run ("delete write errors" , func (mt * mtest.T ) {
1508
+ mt .RunOpts ("delete write errors" , mtest .NewOptions ().MaxServerVersion ("5.2" ), func (mt * mtest.T ) {
1509
+ // Deletes are not allowed on capped collections on MongoDB 5.2-. We use this
1510
+ // behavior to test the processing of write errors.
1505
1511
doc := mongo .NewDeleteOneModel ().SetFilter (bson.D {{"x" , 1 }})
1506
1512
models := []mongo.WriteModel {doc , doc }
1507
1513
cappedOpts := bson.D {{"capped" , true }, {"size" , 64 * 1024 }}
@@ -1598,9 +1604,10 @@ func TestCollection(t *testing.T) {
1598
1604
assert .Equal (mt , expectedModel , actualModel , "expected model %v in BulkWriteException, got %v" ,
1599
1605
expectedModel , actualModel )
1600
1606
})
1601
- mt .Run ("unordered writeError index" , func (mt * mtest.T ) {
1607
+ mt .RunOpts ("unordered writeError index" , mtest .NewOptions ().MaxServerVersion ("5.2" ), func (mt * mtest.T ) {
1608
+ // Deletes are not allowed on capped collections on MongoDB 5.2-. We use this
1609
+ // behavior to test the processing of write errors.
1602
1610
cappedOpts := bson.D {{"capped" , true }, {"size" , 64 * 1024 }}
1603
- // Use a capped collection to get WriteErrors for delete operations
1604
1611
capped := mt .CreateCollection (mtest.Collection {
1605
1612
Name : "deleteOne_capped" ,
1606
1613
CreateOpts : cappedOpts ,
0 commit comments