24
24
*/
25
25
26
26
/* clang-format off */
27
+ #include <assert.h>
27
28
#include <mongoc/mongoc.h>
28
29
#include <mongoc/mongoc-util-private.h>
29
30
#include <mongoc/mongoc-database-private.h>
@@ -3435,6 +3436,20 @@ get_client (void)
3435
3436
return test_framework_new_default_client ();
3436
3437
}
3437
3438
3439
+ /* Returns a test client without version API options configured. */
3440
+ static mongoc_client_t *
3441
+ get_client_for_version_api_example (void ) {
3442
+ mongoc_client_t * client ;
3443
+ mongoc_uri_t * uri ;
3444
+
3445
+ uri = test_framework_get_uri ();
3446
+ client = mongoc_client_new_from_uri (uri );
3447
+ ASSERT (client );
3448
+ test_framework_set_ssl_opts (client );
3449
+ mongoc_uri_destroy (uri );
3450
+ return client ;
3451
+ }
3452
+
3438
3453
static bool
3439
3454
callback (mongoc_client_session_t * session ,
3440
3455
void * ctx ,
@@ -3592,12 +3607,13 @@ _test_sample_versioned_api_example_1 (void)
3592
3607
* client = mongoc_client_new (uri_sharded);
3593
3608
*/
3594
3609
3595
- client = get_client ();
3610
+ /* Create a mongoc_client_t without server API options configured. */
3611
+ client = get_client_for_version_api_example ();
3596
3612
3597
3613
mongoc_server_api_version_from_string ("1" , & server_api_version );
3598
3614
server_api = mongoc_server_api_new (server_api_version );
3599
3615
3600
- mongoc_client_set_server_api (client , server_api , & error );
3616
+ assert ( mongoc_client_set_server_api (client , server_api , & error ) );
3601
3617
/* End Versioned API Example 1 */
3602
3618
3603
3619
mongoc_client_destroy (client );
@@ -3624,13 +3640,14 @@ _test_sample_versioned_api_example_2 (void)
3624
3640
* client = mongoc_client_new (uri_sharded);
3625
3641
*/
3626
3642
3627
- client = get_client ();
3643
+ /* Create a mongoc_client_t without server API options configured. */
3644
+ client = get_client_for_version_api_example ();
3628
3645
3629
3646
mongoc_server_api_version_from_string ("1" , & server_api_version );
3630
3647
server_api = mongoc_server_api_new (server_api_version );
3631
3648
mongoc_server_api_strict (server_api , true);
3632
3649
3633
- mongoc_client_set_server_api (client , server_api , & error );
3650
+ assert ( mongoc_client_set_server_api (client , server_api , & error ) );
3634
3651
/* End Versioned API Example 2 */
3635
3652
3636
3653
mongoc_client_destroy (client );
@@ -3657,13 +3674,14 @@ _test_sample_versioned_api_example_3 (void)
3657
3674
* client = mongoc_client_new (uri_sharded);
3658
3675
*/
3659
3676
3660
- client = get_client ();
3677
+ /* Create a mongoc_client_t without server API options configured. */
3678
+ client = get_client_for_version_api_example ();
3661
3679
3662
3680
mongoc_server_api_version_from_string ("1" , & server_api_version );
3663
3681
server_api = mongoc_server_api_new (server_api_version );
3664
3682
mongoc_server_api_strict (server_api , false);
3665
3683
3666
- mongoc_client_set_server_api (client , server_api , & error );
3684
+ assert ( mongoc_client_set_server_api (client , server_api , & error ) );
3667
3685
/* End Versioned API Example 3 */
3668
3686
3669
3687
mongoc_client_destroy (client );
@@ -3690,13 +3708,14 @@ _test_sample_versioned_api_example_4 (void)
3690
3708
* client = mongoc_client_new (uri_sharded);
3691
3709
*/
3692
3710
3693
- client = get_client ();
3711
+ /* Create a mongoc_client_t without server API options configured. */
3712
+ client = get_client_for_version_api_example ();
3694
3713
3695
3714
mongoc_server_api_version_from_string ("1" , & server_api_version );
3696
3715
server_api = mongoc_server_api_new (server_api_version );
3697
3716
mongoc_server_api_deprecation_errors (server_api , true);
3698
3717
3699
- mongoc_client_set_server_api (client , server_api , & error );
3718
+ assert ( mongoc_client_set_server_api (client , server_api , & error ) );
3700
3719
/* End Versioned API Example 4 */
3701
3720
3702
3721
mongoc_client_destroy (client );
@@ -3725,7 +3744,8 @@ static void _test_sample_versioned_api_example_5_6_7_8 (void) {
3725
3744
int64_t count ;
3726
3745
bson_t * filter ;
3727
3746
3728
- client = get_client ();
3747
+ /* Create a mongoc_client_t without server API options configured. */
3748
+ client = get_client_for_version_api_example ();
3729
3749
mongoc_client_set_error_api (client , MONGOC_ERROR_API_VERSION_2 );
3730
3750
mongoc_server_api_version_from_string ("1" , & server_api_version );
3731
3751
server_api = mongoc_server_api_new (server_api_version );
0 commit comments