-
Notifications
You must be signed in to change notification settings - Fork 995
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
Fix testifylint
lint errors
#1321
Open
jasikpark
wants to merge
7
commits into
slackhq:master
Choose a base branch
from
jasikpark:fixing-expected-actual-errors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jasikpark
force-pushed
the
fixing-expected-actual-errors
branch
from
January 29, 2025 18:22
ca0b825
to
1ea72b2
Compare
jasikpark
commented
Jan 29, 2025
@@ -352,7 +352,7 @@ func TestFirewall_Drop2(t *testing.T) { | |||
cp := cert.NewCAPool() | |||
|
|||
// h1/c1 lacks the proper groups | |||
assert.Error(t, fw.Drop(p, true, &h1, cp, nil), ErrNoMatchingRule) | |||
assert.ErrorIs(t, fw.Drop(p, true, &h1, cp, nil), ErrInvalidRemoteIP) |
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.
fw.Drop
catches the fact that h1
is initialized w/o a valid vpnIp before it actually checks the firewall rule later.
Caught by this block:
Lines 435 to 439 in 2b427a7
// Simple case: Certificate has one IP and no subnets | |
if fp.RemoteIP != h.vpnIp { | |
f.metrics(incoming).droppedRemoteIP.Inc(1) | |
return ErrInvalidRemoteIP | |
} |
jasikpark
requested review from
nbrownus,
johnmaguire and
wadey
and removed request for
nbrownus and
johnmaguire
January 29, 2025 18:31
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://github.com/Antonboom/testifylint contains lints for validating that you avoid pitfalls of using
testify
.I fixed all of the rules except for require-error which asks you to use
require.Error
instead ofassert.Error
because it callst.FailNow()
and makes it less likely that you accidentally swallow the resulting error.Mostly it's syntactical style and better error messages, plus fixing cases where "expected" and "actual" were switched, making error messages more confusing.
There was one case where we were testing whether an error was an error, rather than whether it matched the error in question, caught by error-is-as