Skip to content

Commit 032b66f

Browse files
committed
CDRIVER-1159 test empty aggregate
1 parent 18d66c1 commit 032b66f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/test-mongoc-collection.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,15 +1838,21 @@ test_aggregate (void)
18381838
broken_pipeline = BCON_NEW ("pipeline", "[", "{", "$asdf", "{", "foo", BCON_UTF8 ("bar"), "}", "}", "]");
18391839
b = BCON_NEW ("hello", BCON_UTF8 ("world"));
18401840

1841-
again:
1842-
mongoc_collection_drop(collection, &error);
1841+
/* empty collection */
1842+
cursor = mongoc_collection_aggregate (collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL);
1843+
ASSERT (cursor);
1844+
1845+
ASSERT (!mongoc_cursor_next (cursor, &doc));
1846+
ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error);
1847+
mongoc_cursor_destroy (cursor);
18431848

18441849
for (i = 0; i < 2; i++) {
18451850
ASSERT_OR_PRINT (mongoc_collection_insert(
18461851
collection,
18471852
MONGOC_INSERT_NONE, b, NULL, &error), error);
18481853
}
18491854

1855+
again:
18501856
cursor = mongoc_collection_aggregate (collection, MONGOC_QUERY_NONE, broken_pipeline, NULL, NULL);
18511857
ASSERT (cursor);
18521858

0 commit comments

Comments
 (0)