-
Notifications
You must be signed in to change notification settings - Fork 8
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
empty: report special message for len and string-cast cases #149
Labels
bug
Something isn't working
Milestone
Comments
NotEmptyf
message may be improved.NotEmptyf
message may be improved
I think you already know that but it's the same for I have not tested all the assertions. package sandbox
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestName(t *testing.T) {
assert.NotEmptyf(t, len([]string{"e"}), "text: %s", "a")
assert.NotEmptyf(t, []string{"e"}, "text: %s", "a")
assert.NotEmpty(t, len([]string{"e"}))
assert.NotEmpty(t, []string{"e"})
assert.Emptyf(t, len([]string{"e"}), "text: %s", "a")
assert.Emptyf(t, []string{"e"}, "text: %s", "a")
assert.Empty(t, len([]string{"e"}))
assert.Empty(t, []string{"e"})
} $ ./golangci-lint run --enable-only testifylint
main_test.go:10:2: empty: use assert.NotEmptyf (testifylint)
assert.NotEmptyf(t, len([]string{"e"}), "text: %s", "a")
^
main_test.go:13:2: empty: use assert.NotEmpty (testifylint)
assert.NotEmpty(t, len([]string{"e"}))
^
main_test.go:16:2: empty: use assert.Emptyf (testifylint)
assert.Emptyf(t, len([]string{"e"}), "text: %s", "a")
^
main_test.go:19:2: empty: use assert.Empty (testifylint)
assert.Empty(t, len([]string{"e"}))
^ |
Good catch, the way it reports now could let people think it's a false negative, while it's not, testifylint suggests to simplify. So I agree with you the message needs to be adapted |
NotEmptyf
message may be improved
After fix:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used a version of golangci-lint that uses testifylint v1.4.3.
The text was updated successfully, but these errors were encountered: