From 5477be644a55ce137dec639e57d300d671e5300c Mon Sep 17 00:00:00 2001 From: Benjamin Rewis <32186188+benjirewis@users.noreply.github.com> Date: Tue, 22 Feb 2022 14:29:16 -0500 Subject: [PATCH] GODRIVER-2315 Update tests that expect errors with capped collection deletes (#854) --- mongo/integration/collection_test.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mongo/integration/collection_test.go b/mongo/integration/collection_test.go index 02b421de64..5cc33abbba 100644 --- a/mongo/integration/collection_test.go +++ b/mongo/integration/collection_test.go @@ -308,7 +308,9 @@ func TestCollection(t *testing.T) { assert.Nil(mt, err, "DeleteOne error: %v", err) assert.Equal(mt, int64(0), res.DeletedCount, "expected DeletedCount 0, got %v", res.DeletedCount) }) - mt.Run("write error", func(mt *mtest.T) { + mt.RunOpts("write error", mtest.NewOptions().MaxServerVersion("5.2"), func(mt *mtest.T) { + // Deletes are not allowed on capped collections on MongoDB 5.2-. We use this + // behavior to test the processing of write errors. cappedOpts := bson.D{{"capped", true}, {"size", 64 * 1024}} capped := mt.CreateCollection(mtest.Collection{ Name: "deleteOne_capped", @@ -375,7 +377,9 @@ func TestCollection(t *testing.T) { assert.Nil(mt, err, "DeleteMany error: %v", err) assert.Equal(mt, int64(0), res.DeletedCount, "expected DeletedCount 0, got %v", res.DeletedCount) }) - mt.Run("write error", func(mt *mtest.T) { + mt.RunOpts("write error", mtest.NewOptions().MaxServerVersion("5.2"), func(mt *mtest.T) { + // Deletes are not allowed on capped collections on MongoDB 5.2-. We use this + // behavior to test the processing of write errors. cappedOpts := bson.D{{"capped", true}, {"size", 64 * 1024}} capped := mt.CreateCollection(mtest.Collection{ Name: "deleteMany_capped", @@ -1501,7 +1505,9 @@ func TestCollection(t *testing.T) { }) } }) - mt.Run("delete write errors", func(mt *mtest.T) { + mt.RunOpts("delete write errors", mtest.NewOptions().MaxServerVersion("5.2"), func(mt *mtest.T) { + // Deletes are not allowed on capped collections on MongoDB 5.2-. We use this + // behavior to test the processing of write errors. doc := mongo.NewDeleteOneModel().SetFilter(bson.D{{"x", 1}}) models := []mongo.WriteModel{doc, doc} cappedOpts := bson.D{{"capped", true}, {"size", 64 * 1024}} @@ -1598,9 +1604,10 @@ func TestCollection(t *testing.T) { assert.Equal(mt, expectedModel, actualModel, "expected model %v in BulkWriteException, got %v", expectedModel, actualModel) }) - mt.Run("unordered writeError index", func(mt *mtest.T) { + mt.RunOpts("unordered writeError index", mtest.NewOptions().MaxServerVersion("5.2"), func(mt *mtest.T) { + // Deletes are not allowed on capped collections on MongoDB 5.2-. We use this + // behavior to test the processing of write errors. cappedOpts := bson.D{{"capped", true}, {"size", 64 * 1024}} - // Use a capped collection to get WriteErrors for delete operations capped := mt.CreateCollection(mtest.Collection{ Name: "deleteOne_capped", CreateOpts: cappedOpts,