-
Notifications
You must be signed in to change notification settings - Fork 50
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
Update select_first_candidate
to return InternalSelectionError::Empty
#542
base: master
Are you sure you want to change the base?
Update select_first_candidate
to return InternalSelectionError::Empty
#542
Conversation
Hi there! I'm new here. I didn't see this covered in any existing tests, unless you'd like me to add one? |
If you are up to adding a test that'd be a welcome addition |
Pull Request Test Coverage Report for Build 13667156981Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Also, currently we actually check for an empty candidates set twice: the first one is here. So this specific code change would be unreachable unless calling |
Yes please remove the empty check in |
c113c09
to
57d21c0
Compare
I made the requested changes. |
@pseudoramdom Do you mind squashing your commits into one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small nit to keep the test signatures consistent
c5aa1ea
to
5066eef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 5066eef
Thanks @pseudoramdom and reviewers!
nit: looks like all previous commit messages got squashed into this one, it would be nice to clean up the commit message before merging this. We generally follow the commit guidelines established in https://cbea.ms/git-commit/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than the commit messages. Please follow the seven rules from cbeams.
Thank you for your contribution 😎
…pty` Fix payjoin#535 - Update select_first_candidate to return InternalSelectionError::Empty when there are no candidates available for selection. - Include test `empty_candidates_inputs`
5066eef
to
25d2af5
Compare
Thanks for the reviews folks! Fixed the commit message. Let me know if it looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. I think there is one sincere issue with the test, as discovered by @elnosh in another PR that I've repeated in my comments below.
I would like to understand the rationale of the change in the PR body, in complete sentences, rather than just a repeat of the title. The commit message is closer but I still need it to follow the seven rules, namely 2, 6, and 7, seem broken to me. Much more important than the what is the why, or rationale for the change.
if let Err(err) = result { | ||
let debug_str = format!("{:?}", err); | ||
assert!( | ||
debug_str.contains("Empty"), | ||
"Error should indicate 'Empty' but was: {}", | ||
debug_str | ||
); | ||
} | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern will ignore an Ok result where there should be an error. Instead match
, panic!
on the Ok
case and assert!
on the Err
case as pointed out by @elnosh
@@ -847,6 +845,42 @@ pub(crate) mod test { | |||
} | |||
} | |||
|
|||
#[test] | |||
fn empty_candidates_inputs() -> Result<(), BoxError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can take advantage of the BoxError here by using ?
to propagate errors instead of calling .expect
. Doing so will make the test more brief and readable.
A followup commit might make this change to use BoxError
in the other tests in this module.
Fix #535
Update
select_first_candidate
to returnInternalSelectionError::Empty
when there are no candidates available for selection