|
25 | 25 |
|
26 | 26 | #include <bsoncxx/test/catch.hh>
|
27 | 27 |
|
| 28 | +#include <catch2/matchers/catch_matchers_string.hpp> |
| 29 | + |
28 | 30 | namespace {
|
29 | 31 | TEST_CASE("URI", "[uri]") {
|
30 | 32 | SECTION("Default URI") {
|
@@ -72,9 +74,16 @@ TEST_CASE("URI", "[uri]") {
|
72 | 74 | } catch (mongocxx::logic_error const& e) {
|
73 | 75 | REQUIRE(e.code() == mongocxx::error_code::k_invalid_uri);
|
74 | 76 |
|
75 | | - std::string invalid_schema = "Invalid URI Schema, expecting 'mongodb://' or 'mongodb+srv://': "; |
76 | | - |
77 | | - REQUIRE(e.what() == invalid_schema + e.code().message()); |
| 77 | + // Message format slightly changes between mongoc 2.0.0 and 2.1.0. (CDRIVER-5983) |
| 78 | + // Invalid URI Schema, expecting 'mongodb://' or 'mongodb+srv://': ... |
| 79 | + // -> |
| 80 | + // Invalid URI scheme "mongo://". Expected one of "mongodb://" or "mongodb+srv://": ... |
| 81 | + // https://github.com/mongodb/mongo-c-driver/commit/e388c29bc12b9d9568cde4fca6f95f6fba3289aa#diff-dbe89a1dfeb43b78de3fd2a755697ea837b1e6f6cc8fd589476e64d4fb873700R1985-R1987 |
| 82 | + REQUIRE_THAT( |
| 83 | + e.what(), |
| 84 | + Catch::Matchers::ContainsSubstring("Invalid URI") && Catch::Matchers::ContainsSubstring("mongodb://") && |
| 85 | + Catch::Matchers::ContainsSubstring("mongodb+srv://") && |
| 86 | + Catch::Matchers::ContainsSubstring(e.code().message())); |
78 | 87 | }
|
79 | 88 | }
|
80 | 89 |
|
|
0 commit comments