TEST_CASE("find_one_and_update works with unacknowledged write concern", "[collection]") {
|
instance::current();
|
mongocxx::client client{uri{}, test_util::add_test_server_api()};
|
mongocxx::write_concern wc;
|
wc.acknowledge_level(mongocxx::write_concern::level::k_unacknowledged);
|
|
auto collection = client["fam_wc"]["collection"];
|
collection.drop();
|
collection.insert_one(make_document(kvp("x", 1)));
|
|
stdx::optional<bsoncxx::document::value> doc;
|
mongocxx::options::find_one_and_update find_one_and_update_opts;
|
find_one_and_update_opts.write_concern(wc);
|
// find_one_and_update gets an exception with message:
|
// "cannot return the type of uninitialized element: unset document::element"
|
doc = collection.find_one_and_update(
|
{}, make_document(kvp("$set", make_document(kvp("x", 2)))), find_one_and_update_opts);
|
REQUIRE(!doc);
|
}
|