Skip to content

Commit

Permalink
GODRIVER-2315 Update tests that expect errors with capped collection …
Browse files Browse the repository at this point in the history
…deletes (#854)
  • Loading branch information
benjirewis committed Mar 1, 2022
1 parent 744f96b commit 5477be6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions mongo/integration/collection_test.go
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5477be6

Please sign in to comment.