Skip to content

Commit

Permalink
chore: replace 'assert' with 'require' for critical checks (#2824)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelLau authored Oct 14, 2024
1 parent 37cc44b commit cc71645
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions from_dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/image"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand All @@ -38,7 +37,7 @@ func TestBuildImageFromDockerfile(t *testing.T) {
// }
})
require.NoError(t, err)
assert.Equal(t, "test-repo:test-tag", tag)
require.Equal(t, "test-repo:test-tag", tag)

_, _, err = cli.ImageInspectWithRaw(ctx, tag)
require.NoError(t, err)
Expand Down Expand Up @@ -73,7 +72,7 @@ func TestBuildImageFromDockerfile_NoRepo(t *testing.T) {
},
})
require.NoError(t, err)
assert.True(t, strings.HasPrefix(tag, "test-repo:"))
require.True(t, strings.HasPrefix(tag, "test-repo:"))

_, _, err = cli.ImageInspectWithRaw(ctx, tag)
require.NoError(t, err)
Expand Down Expand Up @@ -130,7 +129,7 @@ func TestBuildImageFromDockerfile_NoTag(t *testing.T) {
},
})
require.NoError(t, err)
assert.True(t, strings.HasSuffix(tag, ":test-tag"))
require.True(t, strings.HasSuffix(tag, ":test-tag"))

_, _, err = cli.ImageInspectWithRaw(ctx, tag)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion modules/etcd/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestRun(t *testing.T) {

c, r, err := ctr.Exec(ctx, []string{"etcdctl", "member", "list"}, tcexec.Multiplexed())
require.NoError(t, err)
require.Equal(t, 0, c)
require.Zero(t, c)

output, err := io.ReadAll(r)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion modules/vault/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestVault(t *testing.T) {
exec, reader, err := vaultContainer.Exec(ctx, []string{"vault", "kv", "get", "-format=json", "secret/test1"})
// }
require.NoError(t, err)
assert.Equal(t, 0, exec)
require.Zero(t, exec)

bytes, err := io.ReadAll(reader)
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ func TestWithStartupCommand(t *testing.T) {
err := testcontainers.WithStartupCommand(testExec)(&req)
require.NoError(t, err)

assert.Len(t, req.LifecycleHooks, 1)
assert.Len(t, req.LifecycleHooks[0].PostStarts, 1)
require.Len(t, req.LifecycleHooks, 1)
require.Len(t, req.LifecycleHooks[0].PostStarts, 1)

c, err := testcontainers.GenericContainer(context.Background(), req)
testcontainers.CleanupContainer(t, c)
Expand Down Expand Up @@ -144,8 +144,8 @@ func TestWithAfterReadyCommand(t *testing.T) {
err := testcontainers.WithAfterReadyCommand(testExec)(&req)
require.NoError(t, err)

assert.Len(t, req.LifecycleHooks, 1)
assert.Len(t, req.LifecycleHooks[0].PostReadies, 1)
require.Len(t, req.LifecycleHooks, 1)
require.Len(t, req.LifecycleHooks[0].PostReadies, 1)

c, err := testcontainers.GenericContainer(context.Background(), req)
testcontainers.CleanupContainer(t, c)
Expand Down

0 comments on commit cc71645

Please sign in to comment.