1
1
#include <bcon.h>
2
2
#include <mongoc.h>
3
3
#include <mongoc-client-private.h>
4
+ #include <mongoc-cursor-private.h>
4
5
5
6
#include "TestSuite.h"
6
7
@@ -1298,6 +1299,7 @@ test_aggregate (void)
1298
1299
bool r ;
1299
1300
bson_t opts ;
1300
1301
bson_t * pipeline ;
1302
+ bson_t * broken_pipeline ;
1301
1303
bson_t * b ;
1302
1304
bson_iter_t iter ;
1303
1305
int i , j ;
@@ -1312,6 +1314,7 @@ test_aggregate (void)
1312
1314
ASSERT (collection );
1313
1315
1314
1316
pipeline = BCON_NEW ("pipeline" , "[" , "{" , "$match" , "{" , "hello" , BCON_UTF8 ("world" ), "}" , "}" , "]" );
1317
+ broken_pipeline = BCON_NEW ("pipeline" , "[" , "{" , "$asdf" , "{" , "foo" , BCON_UTF8 ("bar" ), "}" , "}" , "]" );
1315
1318
b = BCON_NEW ("hello" , BCON_UTF8 ("world" ));
1316
1319
1317
1320
again :
@@ -1323,6 +1326,15 @@ test_aggregate (void)
1323
1326
MONGOC_INSERT_NONE , b , NULL , & error ), error );
1324
1327
}
1325
1328
1329
+ cursor = mongoc_collection_aggregate (collection , MONGOC_QUERY_NONE , broken_pipeline , NULL , NULL );
1330
+ ASSERT (cursor );
1331
+
1332
+ r = mongoc_cursor_next (cursor , & doc );
1333
+ ASSERT (!r );
1334
+ ASSERT (mongoc_cursor_error (cursor , & error ));
1335
+ ASSERT (cursor -> failed );
1336
+ ASSERT (error .code == 16436 );
1337
+
1326
1338
for (i = 0 ; i < 2 ; i ++ ) {
1327
1339
if (i % 2 == 0 ) {
1328
1340
cursor = mongoc_collection_aggregate (collection , MONGOC_QUERY_NONE , pipeline , NULL , NULL );
@@ -1385,6 +1397,7 @@ test_aggregate (void)
1385
1397
mongoc_client_destroy (client );
1386
1398
bson_destroy (b );
1387
1399
bson_destroy (pipeline );
1400
+ bson_destroy (broken_pipeline );
1388
1401
}
1389
1402
1390
1403
0 commit comments