@@ -1498,19 +1498,17 @@ test_multiple_error_ordered_bulk ()
1498
1498
1499
1499
mongoc_bulk_operation_insert (bulk ,
1500
1500
tmp_bson ("{'b': 1, 'a': 1}" ));
1501
- mongoc_bulk_operation_update (bulk ,
1502
- tmp_bson ("{'b': 2}" ),
1503
- tmp_bson ("{'$set': {'a': 1}}" ), true);
1501
+ /* succeeds */
1504
1502
mongoc_bulk_operation_update (bulk ,
1505
1503
tmp_bson ("{'b': 3}" ),
1506
1504
tmp_bson ("{'$set': {'a': 2}}" ), true);
1505
+ /* fails, duplicate value for 'a' */
1507
1506
mongoc_bulk_operation_update (bulk ,
1508
1507
tmp_bson ("{'b': 2}" ),
1509
1508
tmp_bson ("{'$set': {'a': 1}}" ), true);
1509
+ /* not attempted, bulk is already aborted */
1510
1510
mongoc_bulk_operation_insert (bulk ,
1511
1511
tmp_bson ("{'b': 4, 'a': 3}" ));
1512
- mongoc_bulk_operation_insert (bulk ,
1513
- tmp_bson ("{'b': 5, 'a': 1}" ));
1514
1512
1515
1513
r = (bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1516
1514
assert (!r );
@@ -1520,7 +1518,7 @@ test_multiple_error_ordered_bulk ()
1520
1518
/* TODO: CDRIVER-651, assert contents of the 'op' field */
1521
1519
/* TODO: CDRIVER-656, assert writeErrors index is 1 */
1522
1520
ASSERT_MATCH (& reply , "{'nMatched': 0,"
1523
- " 'nUpserted': 0 ,"
1521
+ " 'nUpserted': 1 ,"
1524
1522
" 'nInserted': 1,"
1525
1523
" 'nRemoved': 0,"
1526
1524
/*
@@ -1533,7 +1531,7 @@ test_multiple_error_ordered_bulk ()
1533
1531
"}" );
1534
1532
check_n_modified (has_write_cmds , & reply , 0 );
1535
1533
assert_error_count (1 , & reply );
1536
- assert_count (1 , collection );
1534
+ assert_count (2 , collection );
1537
1535
1538
1536
bson_destroy (& reply );
1539
1537
mongoc_bulk_operation_destroy (bulk );
@@ -1751,8 +1749,8 @@ test_large_inserts_ordered ()
1751
1749
client = test_framework_client_new (NULL );
1752
1750
assert (client );
1753
1751
1754
- huge_doc = BCON_NEW ('a' , BCON_INT32 (1 ));
1755
- bson_append_utf8 (huge_doc , "huge " , -1 ,
1752
+ huge_doc = BCON_NEW ("a" , BCON_INT32 (1 ));
1753
+ bson_append_utf8 (huge_doc , "long-key-to-make-this-fail " , -1 ,
1756
1754
huge_string (client ), huge_string_length (client ));
1757
1755
1758
1756
collection = get_test_collection (client , "test_large_inserts_ordered" );
@@ -1766,7 +1764,7 @@ test_large_inserts_ordered ()
1766
1764
1767
1765
r = (bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1768
1766
assert (!r );
1769
- ASSERT_CMPINT (error .domain , = = , MONGOC_ERROR_COMMAND );
1767
+ ASSERT_CMPINT (error .domain , = = , MONGOC_ERROR_QUERY );
1770
1768
assert (error .code );
1771
1769
1772
1770
/* TODO: CDRIVER-654, assert nInserted == 1 */
@@ -1822,8 +1820,8 @@ test_large_inserts_unordered ()
1822
1820
client = test_framework_client_new (NULL );
1823
1821
assert (client );
1824
1822
1825
- huge_doc = tmp_bson ("{'a': 1}" );
1826
- bson_append_utf8 (huge_doc , "huge " , -1 ,
1823
+ huge_doc = BCON_NEW ("a" , BCON_INT32 ( 1 ) );
1824
+ bson_append_utf8 (huge_doc , "long-key-to-make-this-fail " , -1 ,
1827
1825
huge_string (client ), huge_string_length (client ));
1828
1826
1829
1827
collection = get_test_collection (client , "test_large_inserts_unordered" );
@@ -1837,7 +1835,7 @@ test_large_inserts_unordered ()
1837
1835
1838
1836
r = (bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1839
1837
assert (!r );
1840
- ASSERT_CMPINT (error .domain , = = , MONGOC_ERROR_COMMAND );
1838
+ ASSERT_CMPINT (error .domain , = = , MONGOC_ERROR_QUERY );
1841
1839
assert (error .code );
1842
1840
1843
1841
/* TODO: CDRIVER-654, assert nInserted == 2 */
@@ -1868,6 +1866,7 @@ test_large_inserts_unordered ()
1868
1866
assert_count (6, collection);
1869
1867
*/
1870
1868
1869
+ bson_destroy (huge_doc );
1871
1870
bson_destroy (& reply );
1872
1871
mongoc_bulk_operation_destroy (bulk );
1873
1872
mongoc_collection_destroy (collection );
@@ -2177,6 +2176,10 @@ test_bulk_install (TestSuite *suite)
2177
2176
test_upsert_unordered );
2178
2177
TestSuite_Add (suite , "/BulkOperation/upsert_large" ,
2179
2178
test_upsert_large );
2179
+ TestSuite_Add (suite , "/BulkOperation/upserted_index_ordered" ,
2180
+ test_upserted_index_ordered );
2181
+ TestSuite_Add (suite , "/BulkOperation/upserted_index_unordered" ,
2182
+ test_upserted_index_unordered );
2180
2183
TestSuite_Add (suite , "/BulkOperation/update_one_ordered" ,
2181
2184
test_update_one_ordered );
2182
2185
TestSuite_Add (suite , "/BulkOperation/update_one_unordered" ,
0 commit comments