testifylint
testifylint copied to clipboard
feature: Use `Contains` instead of `strings.Contains`
Using assert.True on strings.Contains does not print out useful information about the arguments in the case of a failure.
assert.Contains, on the other hand, will report both values on failure.
❌
assert.True(t, strings.Contains(s, "abc123"))
assert.True(t, strings.Contains(string(b), "abc123"))
✅
assert.Contains(t, s, "abc123")
assert.Contains(t, string(b), "abc123")
assert.Contains doesn't seem to work well with byte slices, so users would need to convert the bytes to strings. Consequently, I'm not too sure about including bytes.Contains in the same lint rule.
Hi, @nickajacks1!
Thank you for proposal.
assert.Contains doesn't seem to work well with byte slices
offtop: maybe to open issue/PR in testify?
Good idea, I'll look into that and report back here.
Full-featured implementation is blocked by https://github.com/stretchr/testify/pull/1526