From aac2623115f225f287f3afacf5d90348dff66967 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 1 Aug 2025 16:34:15 +0200 Subject: [PATCH] integration/container: TestCheckpoint: inline containerExec util Signed-off-by: Sebastiaan van Stijn --- integration/container/checkpoint_test.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/integration/container/checkpoint_test.go b/integration/container/checkpoint_test.go index a40de80c15..ff94859a64 100644 --- a/integration/container/checkpoint_test.go +++ b/integration/container/checkpoint_test.go @@ -1,7 +1,6 @@ package container import ( - "context" "os/exec" "regexp" "sort" @@ -10,7 +9,6 @@ import ( "github.com/moby/moby/api/types/checkpoint" containertypes "github.com/moby/moby/api/types/container" mounttypes "github.com/moby/moby/api/types/mount" - "github.com/moby/moby/client" "github.com/moby/moby/v2/integration/internal/container" "github.com/moby/moby/v2/testutil/request" "gotest.tools/v3/assert" @@ -19,15 +17,6 @@ import ( "gotest.tools/v3/skip" ) -//nolint:unused // false positive: linter detects this as "unused" -func containerExec(ctx context.Context, t *testing.T, client client.APIClient, cID string, cmd []string) { - t.Logf("Exec: %s", cmd) - r, err := container.Exec(ctx, client, cID, cmd) - assert.NilError(t, err) - t.Log(r.Combined()) - assert.Equal(t, r.ExitCode, 0) -} - func TestCheckpoint(t *testing.T) { t.Skip("TestCheckpoint is broken; see https://github.com/moby/moby/issues/38963") skip.If(t, testEnv.DaemonInfo.OSType == "windows") @@ -94,7 +83,10 @@ func TestCheckpoint(t *testing.T) { assert.Equal(t, checkpoints[0].Name, "test") // Create a test file on a tmpfs mount. - containerExec(ctx, t, apiClient, cID, []string{"touch", "/tmp/test-file"}) + cmd := []string{"touch", "/tmp/test-file"} + r, err := container.Exec(ctx, apiClient, cID, cmd) + assert.NilError(t, err, "failed to exec command:", cmd) + r.AssertSuccess(t) // Do a second checkpoint t.Log("Do a checkpoint and stop the container") @@ -134,7 +126,10 @@ func TestCheckpoint(t *testing.T) { assert.Check(t, is.Equal(true, inspect.State.Running)) // Check that the test file has been restored. - containerExec(ctx, t, apiClient, cID, []string{"test", "-f", "/tmp/test-file"}) + cmd = []string{"test", "-f", "/tmp/test-file"} + r, err = container.Exec(ctx, apiClient, cID, cmd) + assert.NilError(t, err, "failed to exec command:", cmd) + r.AssertSuccess(t) for _, id := range []string{"test", "test2"} { err = apiClient.CheckpointDelete(ctx, cID, checkpoint.DeleteOptions{