Skip to content

Drop gotest.tools#6762

Merged
estesp merged 2 commits intocontainerd:mainfrom
mxpv:testify
Apr 2, 2022
Merged

Drop gotest.tools#6762
estesp merged 2 commits intocontainerd:mainfrom
mxpv:testify

Conversation

@mxpv
Copy link
Copy Markdown
Member

@mxpv mxpv commented Apr 1, 2022

Currently we rely on two different helper libraries for testing:
gotest.tools/v3/assert
github.com/stretchr/testify/assert

Both offer more or less same set of APIs, so there is no reason to keep both.

Looks like testify got better adoption accross containerd's codebase.

❯ grep -r --exclude-dir=vendor "gotest.tools/v3/assert" * | wc -l
      38
❯ grep -r --exclude-dir=vendor "github.com/stretchr/testify/assert" * | wc -l
      78

So this PR migrates tests to testify and drops gotest.tools/v3/assert dependency.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Apr 1, 2022

Build succeeded.

Copy link
Copy Markdown
Member

@samuelkarp samuelkarp left a comment

Choose a reason for hiding this comment

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

LGTM. I left suggestions where I think the use of Testify could be more idiomatic, but I don't think any of those should be blocking.

Comment thread cio/io_test.go Outdated
Comment thread cio/io_unix_test.go Outdated
Comment thread cio/io_windows_test.go
Comment thread cio/io_windows_test.go Outdated
err = tryLock("testref")
assert.ErrorContains(t, err, "ref testref locked for ")
require.NotNil(t, err)
assert.Contains(t, err.Error(), "ref testref locked for ")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
assert.Contains(t, err.Error(), "ref testref locked for ")
assert.ErrorContains(t, err, "ref testref locked for ")

Comment thread snapshots/devmapper/metadata_test.go Outdated
Comment thread snapshots/devmapper/snapshotter_test.go Outdated
Comment thread snapshots/devmapper/snapshotter_test.go Outdated
// We test the default setting which is lazy init is disabled
err := mkfs(ctx, "ext4", "nodiscard,lazy_itable_init=0,lazy_journal_init=0", "")
assert.ErrorContains(t, err, `mkfs.ext4 couldn't initialize ""`)
assert.Contains(t, err.Error(), `mkfs.ext4 couldn't initialize ""`)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
assert.Contains(t, err.Error(), `mkfs.ext4 couldn't initialize ""`)
assert.ErrorContains(t, err, `mkfs.ext4 couldn't initialize ""`)

Comment on lines +274 to +277
assert.NotNil(t, err)
if err != nil {
assert.Contains(t, err.Error(), "remove")
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this can be simplified

Suggested change
assert.NotNil(t, err)
if err != nil {
assert.Contains(t, err.Error(), "remove")
}
assert.ErrorContains(t, err, "remove")

@mxpv
Copy link
Copy Markdown
Member Author

mxpv commented Apr 2, 2022

I've addressed the majority of suggestions.
ErrorContains is not yet included in any release (added after 1.7).
We can revendor their master branch, but I personally would wait till 1.8 release.

mxpv added 2 commits April 1, 2022 18:17
Signed-off-by: Maksym Pavlenko <[email protected]>
Signed-off-by: Maksym Pavlenko <[email protected]>
Copy link
Copy Markdown
Member

@samuelkarp samuelkarp left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Apr 2, 2022

Build succeeded.

@containerd containerd deleted a comment from theopenlab-ci Bot Apr 2, 2022
Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@estesp estesp merged commit aaf64c4 into containerd:main Apr 2, 2022
@mxpv mxpv deleted the testify branch April 3, 2022 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants