Skip to content

CXX-1643 Replace mongoc_uri_new for better exception message #720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2020

Conversation

rayangler
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2020

Codecov Report

Merging #720 into master will decrease coverage by 1.29%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #720      +/-   ##
==========================================
- Coverage   94.28%   92.98%   -1.30%     
==========================================
  Files         357      357              
  Lines       18655    19059     +404     
==========================================
+ Hits        17588    17722     +134     
- Misses       1067     1337     +270     
Impacted Files Coverage Δ
src/mongocxx/private/libmongoc_symbols.hh 100.00% <100.00%> (ø)
src/mongocxx/test/uri.cpp 100.00% <100.00%> (ø)
src/mongocxx/uri.cpp 95.16% <100.00%> (+0.03%) ⬆️
src/mongocxx/test/client_side_encryption.cpp 67.39% <0.00%> (-29.78%) ⬇️
examples/mongocxx/document_validation.cpp 90.47% <0.00%> (-2.86%) ⬇️
examples/mongocxx/query.cpp 79.62% <0.00%> (-0.38%) ⬇️
examples/mongocxx/create.cpp 100.00% <0.00%> (ø)
examples/mongocxx/remove.cpp 100.00% <0.00%> (ø)
examples/mongocxx/update.cpp 100.00% <0.00%> (ø)
examples/mongocxx/view_or_value_variant.cpp 100.00% <0.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3126f18...c18ecbd. Read the comment docs.

@bazile-clyde bazile-clyde self-requested a review September 8, 2020 19:28
Copy link
Contributor

@bazile-clyde bazile-clyde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far! I left a couple of comments that might help with the failing tests on evergreen.

std::string invalid_schema =
"Invalid URI Schema, expecting 'mongodb://' or 'mongodb+srv://': ";

REQUIRE(e.what() == invalid_schema + e.code().message());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this test is necessary but I added it in the moment to make sure we were successfully getting the correct error message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This works. There's also a REQUIRE_THROWS_WITH that takes a regex so you can assert things like "the error contains the words invalid URI" case-insensitively. But no need to change this.

Copy link
Contributor

@bazile-clyde bazile-clyde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
To merge:

  1. Hit the squash and merge button below.
  2. Remove any commit messages from the body box (the one on bottom)
  3. Ensure the commit message (in the top box) follows our standards (here). Leave the postfix "(CXX-1643 Replace mongoc_uri_new for better exception message #720)" too. That'll link to the PR.
  4. Click Confirm squash and merge

std::string invalid_schema =
"Invalid URI Schema, expecting 'mongodb://' or 'mongodb+srv://': ";

REQUIRE(e.what() == invalid_schema + e.code().message());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This works. There's also a REQUIRE_THROWS_WITH that takes a regex so you can assert things like "the error contains the words invalid URI" case-insensitively. But no need to change this.

@rayangler rayangler merged commit 81ebf66 into mongodb:master Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants