@@ -4431,14 +4431,12 @@ test_getmore_read_concern_live (void *ctx)
4431
4431
mongoc_write_concern_set_w (wc , MONGOC_WRITE_CONCERN_W_MAJORITY );
4432
4432
mongoc_collection_set_write_concern (collection , wc );
4433
4433
4434
- for (i = 5000 ; i > 0 ; i -- ) {
4435
- mongoc_collection_insert (collection , MONGOC_INSERT_NONE , tmp_bson
4436
- ("{'a': 1}" ), NULL , NULL );
4434
+ for (i = 5000 ; i > 0 ; i -- ) {
4435
+ mongoc_collection_insert (
4436
+ collection , MONGOC_INSERT_NONE , tmp_bson ("{'a': 1}" ), NULL , NULL );
4437
4437
}
4438
- cursor = mongoc_collection_find_with_opts (collection ,
4439
- tmp_bson ("{}" ),
4440
- NULL ,
4441
- NULL );
4438
+ cursor = mongoc_collection_find_with_opts (
4439
+ collection , tmp_bson ("{}" ), NULL , NULL );
4442
4440
4443
4441
while (mongoc_cursor_next (cursor , & doc )) {
4444
4442
i ++ ;
@@ -4455,7 +4453,6 @@ test_getmore_read_concern_live (void *ctx)
4455
4453
}
4456
4454
4457
4455
4458
-
4459
4456
static void
4460
4457
test_aggregate_read_concern (void )
4461
4458
{
@@ -4737,6 +4734,33 @@ test_insert_duplicate_key (void)
4737
4734
mongoc_client_destroy (client );
4738
4735
}
4739
4736
4737
+ static void
4738
+ test_create_index_fail (void )
4739
+ {
4740
+ mongoc_client_t * client ;
4741
+ mongoc_collection_t * collection ;
4742
+ bool r ;
4743
+ bson_t reply ;
4744
+ bson_error_t error ;
4745
+
4746
+ client = mongoc_client_new ("mongodb://example.com/?connectTimeoutMS=10" );
4747
+ collection = mongoc_client_get_collection (client , "test" , "test" );
4748
+ r = mongoc_collection_create_index_with_opts (
4749
+ collection , tmp_bson ("{'a': 1}" ), NULL , NULL , & reply , & error );
4750
+
4751
+ ASSERT (!r );
4752
+ ASSERT_ERROR_CONTAINS (error ,
4753
+ MONGOC_ERROR_SERVER_SELECTION ,
4754
+ MONGOC_ERROR_SERVER_SELECTION_FAILURE ,
4755
+ "connection timeout" );
4756
+
4757
+ /* reply was initialized */
4758
+ ASSERT (bson_empty (& reply ));
4759
+
4760
+ mongoc_collection_destroy (collection );
4761
+ mongoc_client_destroy (client );
4762
+ }
4763
+
4740
4764
void
4741
4765
test_collection_install (TestSuite * suite )
4742
4766
{
@@ -4882,9 +4906,12 @@ test_collection_install (TestSuite *suite)
4882
4906
TestSuite_Add (suite , "/Collection/stats/read_pref" , test_stats_read_pref );
4883
4907
TestSuite_Add (
4884
4908
suite , "/Collection/find_read_concern" , test_find_read_concern );
4885
- TestSuite_AddFull (
4886
- suite , "/Collection/getmore_read_concern_live" ,
4887
- test_getmore_read_concern_live , NULL , NULL , test_framework_skip_if_max_wire_version_less_than_4 );
4909
+ TestSuite_AddFull (suite ,
4910
+ "/Collection/getmore_read_concern_live" ,
4911
+ test_getmore_read_concern_live ,
4912
+ NULL ,
4913
+ NULL ,
4914
+ test_framework_skip_if_max_wire_version_less_than_4 );
4888
4915
TestSuite_AddLive (
4889
4916
suite , "/Collection/find_and_modify" , test_find_and_modify );
4890
4917
TestSuite_Add (suite ,
@@ -4913,4 +4940,6 @@ test_collection_install (TestSuite *suite)
4913
4940
suite , "/Collection/find_indexes/error" , test_find_indexes_err );
4914
4941
TestSuite_AddLive (
4915
4942
suite , "/Collection/insert/duplicate_key" , test_insert_duplicate_key );
4943
+ TestSuite_Add (
4944
+ suite , "/Collection/create_index/fail" , test_create_index_fail );
4916
4945
}
0 commit comments