From 81bf4b4b676948dfb753f30da48829b9e5b841d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Mon, 5 Feb 2024 16:22:23 +0100 Subject: [PATCH] chore: proper error handling on defer --- main_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main_test.go b/main_test.go index 19ef04f..4fa08e1 100644 --- a/main_test.go +++ b/main_test.go @@ -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) @@ -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") }) }