Skip to content
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

contains: use Contains instead of strings.Contains #54

Closed
nickajacks1 opened this issue Jan 21, 2024 · 3 comments · Fixed by #152
Closed

contains: use Contains instead of strings.Contains #54

nickajacks1 opened this issue Jan 21, 2024 · 3 comments · Fixed by #152
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@nickajacks1
Copy link

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.

@Antonboom Antonboom added the enhancement New feature or request label Jan 23, 2024
@Antonboom
Copy link
Owner

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?

@nickajacks1
Copy link
Author

Good idea, I'll look into that and report back here.

@Antonboom
Copy link
Owner

Antonboom commented Feb 8, 2024

Full-featured implementation is blocked by stretchr/testify#1526

@Antonboom Antonboom added the good first issue Good for newcomers label Apr 7, 2024
@Antonboom Antonboom changed the title feature: Use Contains instead of strings.Contains contains: use Contains instead of strings.Contains Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants