From b43f6e6f34c0157e48cf0815d05ebd17fa2cf9f1 Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Mon, 6 Jan 2025 15:48:10 -0500 Subject: [PATCH] update test case --- internal/integration/collection_test.go | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/internal/integration/collection_test.go b/internal/integration/collection_test.go index c0a3bfedc5..deb9b0f7ba 100644 --- a/internal/integration/collection_test.go +++ b/internal/integration/collection_test.go @@ -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 { @@ -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) }) } })