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

refactor(tests): assert.Error->require.Error (remainder) #13462

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

Joibel
Copy link
Member

@Joibel Joibel commented Aug 13, 2024

This is part of a series of test tidies started by #13365.

The aim is to enable the testifylint golangci-lint checker.

This commit converts assert.Error checks into require.Error for the rest of the code base.

In some places checks have been coaleced - in particular the pattern

if assert.Error() {
    assert.Contains(..., "message")
}

is now

require.ErrorContains(..., "message")

Getting this wrong and missing the Contains is still valid go, so that's a mistake I may have made.

@Joibel Joibel self-assigned this Aug 13, 2024
@Joibel Joibel changed the title chore(tests): assert.Error->require.Error (remainder) chore(tests): assert.Error->require.Error (remainder) Aug 13, 2024
@Joibel Joibel removed their assignment Aug 13, 2024
@Joibel Joibel added the area/build Build or GithubAction/CI issues label Aug 13, 2024
This is part of a series of test tidies started by #13365.

The aim is to enable the testifylint golangci-lint checker.

This commit converts assert.Error checks into require.Error for the
rest of the code base.

In some places checks have been coaleced - in particular the pattern

```go
if assert.Error() {
    assert.Contains(..., "message")
}
```

is now
```go
require.ErrorContains(..., "message")
```

Getting this wrong and missing the Contains is still valid go, so
that's a mistake I may have made.

Signed-off-by: Alan Clucas <alan@clucas.org>
@Joibel Joibel force-pushed the testifylint-require-remaining branch from 84ddac5 to 886146b Compare August 13, 2024 12:25
@Joibel Joibel changed the title chore(tests): assert.Error->require.Error (remainder) refactor(tests): assert.Error->require.Error (remainder) Aug 13, 2024
Copy link
Member

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize there were still some leftover. One question and two small consistency suggestions below, otherwise LGTM

Would you like to tackle the remaining if assert.* -> require.* changes as mentioned in #13401 (comment) etc? the vast majority in my searches were actually Error/NoError, so there should only be a small number remaining

test/e2e/retry_test.go Show resolved Hide resolved
test/e2e/cli_test.go Outdated Show resolved Hide resolved
test/e2e/cli_test.go Outdated Show resolved Hide resolved
Signed-off-by: Anton Gilgur <4970083+agilgur5@users.noreply.github.com>
Copy link
Member

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the changes myself above, LGTM now

@Joibel Joibel enabled auto-merge (squash) August 14, 2024 08:07
@Joibel Joibel merged commit 3f161cb into main Aug 14, 2024
28 checks passed
@Joibel Joibel deleted the testifylint-require-remaining branch August 14, 2024 08:34
@Joibel
Copy link
Member Author

Joibel commented Aug 14, 2024

I didn't realize there were still some leftover.

This is the first bullet point although there are some here outside e2e still, not sure why they were missed before.

Would you like to tackle the remaining if assert.* -> require.* changes as mentioned in #13401 (comment) etc? the vast majority in my searches were actually Error/NoError, so there should only be a small number remaining

I might do, my main target right now around this is getting this linter enabled in CI. I'll track this as an issue.

@Joibel
Copy link
Member Author

Joibel commented Aug 14, 2024

Issue #13465 raised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Build or GithubAction/CI issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants