Skip to content

Commit d06c986

Browse files
benjirewisBenjamin Rewis
authored andcommitted
GODRIVER-2315 Update tests that expect errors with capped collection deletes (#854)
1 parent e4487b4 commit d06c986

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

mongo/integration/collection_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,9 @@ func TestCollection(t *testing.T) {
308308
assert.Nil(mt, err, "DeleteOne error: %v", err)
309309
assert.Equal(mt, int64(0), res.DeletedCount, "expected DeletedCount 0, got %v", res.DeletedCount)
310310
})
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.
312314
cappedOpts := bson.D{{"capped", true}, {"size", 64 * 1024}}
313315
capped := mt.CreateCollection(mtest.Collection{
314316
Name: "deleteOne_capped",
@@ -375,7 +377,9 @@ func TestCollection(t *testing.T) {
375377
assert.Nil(mt, err, "DeleteMany error: %v", err)
376378
assert.Equal(mt, int64(0), res.DeletedCount, "expected DeletedCount 0, got %v", res.DeletedCount)
377379
})
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.
379383
cappedOpts := bson.D{{"capped", true}, {"size", 64 * 1024}}
380384
capped := mt.CreateCollection(mtest.Collection{
381385
Name: "deleteMany_capped",
@@ -1501,7 +1505,9 @@ func TestCollection(t *testing.T) {
15011505
})
15021506
}
15031507
})
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.
15051511
doc := mongo.NewDeleteOneModel().SetFilter(bson.D{{"x", 1}})
15061512
models := []mongo.WriteModel{doc, doc}
15071513
cappedOpts := bson.D{{"capped", true}, {"size", 64 * 1024}}
@@ -1598,9 +1604,10 @@ func TestCollection(t *testing.T) {
15981604
assert.Equal(mt, expectedModel, actualModel, "expected model %v in BulkWriteException, got %v",
15991605
expectedModel, actualModel)
16001606
})
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.
16021610
cappedOpts := bson.D{{"capped", true}, {"size", 64 * 1024}}
1603-
// Use a capped collection to get WriteErrors for delete operations
16041611
capped := mt.CreateCollection(mtest.Collection{
16051612
Name: "deleteOne_capped",
16061613
CreateOpts: cappedOpts,

0 commit comments

Comments
 (0)