17
17
18
18
#include "bson/bson.h"
19
19
20
+ #include "mongoc/mongoc-change-stream-private.h"
20
21
#include "mongoc/mongoc-collection-private.h"
21
22
#include "mongoc/mongoc-config.h"
22
23
#include "mongoc/mongoc-cursor-private.h"
23
24
#include "mongoc/mongoc-host-list-private.h"
24
25
#include "mongoc/mongoc-server-description-private.h"
25
26
#include "mongoc/mongoc-topology-description-private.h"
26
27
#include "mongoc/mongoc-topology-private.h"
27
- #include "mongoc/mongoc-util-private.h"
28
- #include "mongoc/mongoc-util-private.h"
29
28
#include "mongoc/mongoc-uri-private.h"
29
+ #include "mongoc/mongoc-util-private.h"
30
30
31
31
#include "json-test-operations.h"
32
32
#include "json-test.h"
@@ -1759,6 +1759,13 @@ gridfs_download (mongoc_database_t *db,
1759
1759
return true;
1760
1760
}
1761
1761
1762
+ static bool
1763
+ op_error (const bson_t * operation )
1764
+ {
1765
+ return bson_has_field (operation , "error" ) &&
1766
+ bson_lookup_bool (operation , "error" );
1767
+ }
1768
+
1762
1769
bool
1763
1770
json_test_operation (json_test_ctx_t * ctx ,
1764
1771
const bson_t * test ,
@@ -1844,6 +1851,13 @@ json_test_operation (json_test_ctx_t *ctx,
1844
1851
bson_t pipeline = BSON_INITIALIZER ;
1845
1852
mongoc_change_stream_destroy (ctx -> change_stream );
1846
1853
ctx -> change_stream = mongoc_collection_watch (c , & pipeline , NULL );
1854
+ res = (op_error (operation ) == (bool ) ctx -> change_stream -> err .code );
1855
+ if (!res ) {
1856
+ test_error ("expected error=%s, but actual error='%s'" ,
1857
+ op_error (operation ) ? "true" : "false" ,
1858
+ ctx -> change_stream -> err .message );
1859
+ }
1860
+
1847
1861
bson_init (reply );
1848
1862
bson_destroy (& pipeline );
1849
1863
} else if (!strcmp (op_name , "mapReduce" ) ||
@@ -1865,6 +1879,13 @@ json_test_operation (json_test_ctx_t *ctx,
1865
1879
bson_t pipeline = BSON_INITIALIZER ;
1866
1880
mongoc_change_stream_destroy (ctx -> change_stream );
1867
1881
ctx -> change_stream = mongoc_database_watch (db , & pipeline , NULL );
1882
+ res = (op_error (operation ) == (bool ) ctx -> change_stream -> err .code );
1883
+ if (!res ) {
1884
+ test_error ("expected error=%s, but actual error='%s'" ,
1885
+ op_error (operation ) ? "true" : "false" ,
1886
+ ctx -> change_stream -> err .message );
1887
+ }
1888
+
1868
1889
bson_init (reply );
1869
1890
bson_destroy (& pipeline );
1870
1891
} else if (!strcmp (op_name , "listCollectionObjects" )) {
@@ -1912,6 +1933,13 @@ json_test_operation (json_test_ctx_t *ctx,
1912
1933
bson_t pipeline = BSON_INITIALIZER ;
1913
1934
mongoc_change_stream_destroy (ctx -> change_stream );
1914
1935
ctx -> change_stream = mongoc_client_watch (c -> client , & pipeline , NULL );
1936
+ res = (op_error (operation ) == (bool ) ctx -> change_stream -> err .code );
1937
+ if (!res ) {
1938
+ test_error ("expected error=%s, but actual error='%s'" ,
1939
+ op_error (operation ) ? "true" : "false" ,
1940
+ ctx -> change_stream -> err .message );
1941
+ }
1942
+
1915
1943
bson_init (reply );
1916
1944
bson_destroy (& pipeline );
1917
1945
} else if (!strcmp (op_name , "listDatabaseObjects" )) {
0 commit comments