Skip to content

Commit 38f7440

Browse files
committed
Rewrite container remove test
Signed-off-by: apostasie <[email protected]>
1 parent 49a19ed commit 38f7440

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

cmd/nerdctl/container/container_remove_test.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,30 @@ import (
2020
"testing"
2121

2222
"github.com/containerd/nerdctl/v2/pkg/testutil"
23+
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
24+
"github.com/containerd/nerdctl/v2/pkg/testutil/test"
2325
)
2426

2527
func TestRemoveContainer(t *testing.T) {
26-
t.Parallel()
28+
testCase := nerdtest.Setup()
2729

28-
base := testutil.NewBase(t)
29-
tID := testutil.Identifier(t)
30+
testCase.Setup = func(data test.Data, helpers test.Helpers) {
31+
helpers.Ensure("run", "-d", "--name", data.Identifier(), testutil.CommonImage, "sleep", "inf")
32+
}
3033

31-
// ignore error
32-
base.Cmd("rm", tID, "-f").AssertOK()
34+
testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
35+
helpers.Anyhow("rm", "-f", data.Identifier())
36+
}
3337

34-
base.Cmd("run", "-d", "--name", tID, testutil.NginxAlpineImage).AssertOK()
35-
defer base.Cmd("rm", tID, "-f").AssertOK()
36-
base.Cmd("rm", tID).AssertFail()
38+
testCase.Command = func(data test.Data, helpers test.Helpers) test.TestableCommand {
39+
helpers.Fail("rm", data.Identifier())
3740

38-
// `kill` does return before the container actually stops
39-
base.Cmd("stop", tID).AssertOK()
40-
base.Cmd("rm", tID).AssertOK()
41+
// FIXME: should (re-)evaluate this
42+
// `kill` seems to return before the container actually stops
43+
helpers.Ensure("stop", data.Identifier())
44+
45+
return helpers.Command("rm", data.Identifier())
46+
}
47+
48+
testCase.Expected = test.Expects(0, nil, nil)
4149
}

0 commit comments

Comments
 (0)