@@ -234,6 +234,7 @@ _test_opt (const char *opts_json, const char *msg)
234
234
static void
235
235
test_opts (void )
236
236
{
237
+ _test_opt ("{'foo': 1}" , "Invalid option 'foo'" );
237
238
_test_opt ("{'writeConcern': 1}" , "Invalid writeConcern" );
238
239
_test_opt ("{'writeConcern': {'w': 0, 'j': 1}}" , "Invalid writeConcern" );
239
240
_test_opt ("{'sessionId': 'hi'}" , "Invalid sessionId" );
@@ -4450,14 +4451,19 @@ test_bulk_opts_parse (void)
4450
4451
MONGOC_ERROR_COMMAND_INVALID_ARG, \
4451
4452
"Invalid " _msg)
4452
4453
4454
+ RM_ERR ("option 'foo'" , remove_one , tmp_bson ("{'foo': 1}" ));
4455
+ RM_ERR ("option 'foo'" , remove_many , tmp_bson ("{'foo': 1}" ));
4453
4456
RM_ERR ("\"limit\" in opts: 2" , remove_one , tmp_bson ("{'limit': 2}" ));
4454
4457
RM_ERR ("\"limit\" in opts: 2" , remove_many , tmp_bson ("{'limit': 2}" ));
4455
4458
RM_ERR ("\"limit\" in opts: 0" , remove_one , tmp_bson ("{'limit': 0}" ));
4456
4459
RM_ERR ("\"limit\" in opts: 1" , remove_many , tmp_bson ("{'limit': 1}" ));
4457
4460
4461
+ UPDATE_ERR ("option 'foo'" , one , tmp_bson ("{'foo': 1}" ));
4462
+ UPDATE_ERR ("option 'foo'" , many , tmp_bson ("{'foo': 1}" ));
4458
4463
UPDATE_ERR ("\"multi\" in opts: true" , one , tmp_bson ("{'multi': true}" ));
4459
4464
UPDATE_ERR ("\"multi\" in opts: false" , many , tmp_bson ("{'multi': false}" ));
4460
4465
4466
+ REPLACE_ERR ("option 'foo'" , tmp_bson ("{'foo': 1}" ));
4461
4467
REPLACE_ERR ("\"multi\": true in opts" , tmp_bson ("{'multi': true}" ));
4462
4468
4463
4469
#define NO_ERR (_fn , ...) \
@@ -4471,11 +4477,6 @@ test_bulk_opts_parse (void)
4471
4477
NO_ERR (update_one , q , u , tmp_bson ("{'multi': false}" ));
4472
4478
NO_ERR (update_many , q , u , tmp_bson ("{'multi': true}" ));
4473
4479
NO_ERR (replace_one , q , repl , tmp_bson ("{'multi': false}" ));
4474
- NO_ERR (remove_one , q , tmp_bson ("{'foo': 1}" ));
4475
- NO_ERR (remove_many , q , tmp_bson ("{'foo': 1}" ));
4476
- NO_ERR (update_one , q , u , tmp_bson ("{'foo': 1}" ));
4477
- NO_ERR (update_many , q , u , tmp_bson ("{'foo': 1}" ));
4478
- NO_ERR (replace_one , q , repl , tmp_bson ("{'foo': 1}" ));
4479
4480
4480
4481
mongoc_bulk_operation_destroy (bulk );
4481
4482
mongoc_collection_destroy (collection );
@@ -4518,23 +4519,31 @@ test_bulk_bypass_document_validation (void)
4518
4519
client = test_framework_client_new ();
4519
4520
collection = get_test_collection (client , "bypass_validation" );
4520
4521
4521
- /* bypassDocumentValidation can be passed in opts, but is ignored */
4522
+ /* bypassDocumentValidation can't be passed in opts */
4522
4523
bulk = mongoc_collection_create_bulk_operation_with_opts (
4523
4524
collection , tmp_bson ("{'bypassDocumentValidation': true}" ));
4524
4525
4525
4526
i = mongoc_bulk_operation_execute (bulk , NULL , & error );
4526
4527
ASSERT_CMPUINT32 (i , = = , (uint32_t ) 0 );
4528
+ ASSERT_ERROR_CONTAINS (error ,
4529
+ MONGOC_ERROR_COMMAND ,
4530
+ MONGOC_ERROR_COMMAND_INVALID_ARG ,
4531
+ "Invalid option 'bypassDocumentValidation'" );
4527
4532
4528
4533
mongoc_bulk_operation_destroy (bulk );
4529
4534
4530
- /* same for insert opts */
4535
+ /* not allowed in insert opts either */
4531
4536
bulk = mongoc_collection_create_bulk_operation_with_opts (collection , NULL );
4532
4537
r = mongoc_bulk_operation_insert_with_opts (
4533
4538
bulk ,
4534
4539
tmp_bson ("{}" ),
4535
4540
tmp_bson ("{'bypassDocumentValidation': true}" ),
4536
4541
& error );
4537
- BSON_ASSERT (r );
4542
+ BSON_ASSERT (!r );
4543
+ ASSERT_ERROR_CONTAINS (error ,
4544
+ MONGOC_ERROR_COMMAND ,
4545
+ MONGOC_ERROR_COMMAND_INVALID_ARG ,
4546
+ "Invalid option 'bypassDocumentValidation'" );
4538
4547
4539
4548
mongoc_bulk_operation_destroy (bulk );
4540
4549
mongoc_collection_destroy (collection );
0 commit comments