Skip to content

Commit

Permalink
update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Jan 6, 2025
1 parent 0a2e7b8 commit b43f6e6
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions internal/integration/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1719,24 +1719,29 @@ func TestCollection(t *testing.T) {
mt.Parallel()

testCases := []struct {
name string
model mongo.WriteModel
name string
model mongo.WriteModel
errorString string
}{
{
name: "DeleteOne",
model: mongo.NewDeleteOneModel(),
name: "DeleteOne",
model: mongo.NewDeleteOneModel(),
errorString: "delete filter cannot be nil",
},
{
name: "DeleteMany",
model: mongo.NewDeleteManyModel(),
name: "DeleteMany",
model: mongo.NewDeleteManyModel(),
errorString: "delete filter cannot be nil",
},
{
name: "UpdateOne",
model: mongo.NewUpdateOneModel().SetUpdate(bson.D{{"$set", bson.D{{"x", 1}}}}),
name: "UpdateOne",
model: mongo.NewUpdateOneModel().SetUpdate(bson.D{{"$set", bson.D{{"x", 1}}}}),
errorString: "update filter cannot be nil",
},
{
name: "UpdateMany",
model: mongo.NewUpdateManyModel().SetUpdate(bson.D{{"$set", bson.D{{"x", 1}}}}),
name: "UpdateMany",
model: mongo.NewUpdateManyModel().SetUpdate(bson.D{{"$set", bson.D{{"x", 1}}}}),
errorString: "update filter cannot be nil",
},
}
for _, tc := range testCases {
Expand All @@ -1746,7 +1751,7 @@ func TestCollection(t *testing.T) {
mt.Parallel()

_, err := mt.Coll.BulkWrite(context.Background(), []mongo.WriteModel{tc.model})
assert.ErrorContains(mt, err, "filter is required")
assert.EqualError(mt, err, tc.errorString)
})
}
})
Expand Down

0 comments on commit b43f6e6

Please sign in to comment.