Skip to content

Commit

Permalink
chore: proper error handling on defer
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Feb 5, 2024
1 parent 077184c commit 81bf4b4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ func TestPrune(t *testing.T) {
})
require.Nil(t, err)
require.NotNil(t, c)
t.Cleanup(func() {
require.Error(t, c.Terminate(ctx), "container should have been removed")
})
}

dc, dn, dv, di := prune(cli, deathNote)
Expand Down Expand Up @@ -234,7 +237,8 @@ func TestPrune(t *testing.T) {
require.Nil(t, err)
require.NotNil(t, vol)
t.Cleanup(func() {
_ = cli.VolumeRemove(ctx, vol.Name, true)
// force remove the volume, which does not fail if the volume was already removed
require.NoError(t, cli.VolumeRemove(ctx, vol.Name, true), "volume should have been removed")
})
}

Expand Down

0 comments on commit 81bf4b4

Please sign in to comment.