Remove error-chain dependency in tests and test helpers#104
Conversation
dlon
left a comment
There was a problem hiding this comment.
Reviewed 8 of 8 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @faern)
tests/redirect_rules.rs line 52 at r1 (raw file):
assert_matches!(pf.flush_rules(ANCHOR_NAME, pfctl::RulesetKind::Redirect), Ok(())); assert_eq!( pfcli::get_nat_rules(ANCHOR_NAME),
Nit: I think you could replace this with assert!(pfctl::get_nat_rules(ANCHOR_NAME).is_empty()) or assert_eq!(pfctl::get_nat_rules(ANCHOR_NAME).len(), 0).
faern
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dlon)
tests/redirect_rules.rs line 52 at r1 (raw file):
Previously, dlon (David Lönnhager) wrote…
Nit: I think you could replace this with
assert!(pfctl::get_nat_rules(ANCHOR_NAME).is_empty())orassert_eq!(pfctl::get_nat_rules(ANCHOR_NAME).len(), 0).
I can, but it would yield worse error messages. Then it would either just say that my bool was false, or it would say my number was not zero. With this construct the panic message will contain the rules returned (that was not an empty list).
Follow up to #102. I realized we also used
error-chainin tests 🤦. So a step in the direction of removing error-chain completely is to stop using it in tests. I just replaced most error handling withexpect, since expect/unwrap is all we did with the errors we had anyway.Since a lot of the test helper methods became infallible, sadly virtually every test was affected, due to them using the test helpers.
This change is