From d03e93f6f1d45340c2a7bb259cb398a88b4c0945 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Thu, 25 May 2023 13:54:26 +0100 Subject: [PATCH] test: tmpdir can be a test helper Signed-off-by: Justin Chadwell --- tests/build.go | 3 +-- tests/integration.go | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/build.go b/tests/build.go index 71908546..53bc74d2 100644 --- a/tests/build.go +++ b/tests/build.go @@ -148,11 +148,10 @@ RUN cp /etc/foo /etc/bar FROM scratch COPY --from=base /etc/bar /bar `) - dir, err := tmpdir( + dir := tmpdir( t, fstest.CreateFile("Dockerfile", dockerfile, 0600), fstest.CreateFile("foo", []byte("foo"), 0600), ) - require.NoError(t, err) return dir } diff --git a/tests/integration.go b/tests/integration.go index 0a0276bc..a1a860f0 100644 --- a/tests/integration.go +++ b/tests/integration.go @@ -7,14 +7,15 @@ import ( "github.com/containerd/continuity/fs/fstest" "github.com/moby/buildkit/util/testutil/integration" + "github.com/stretchr/testify/require" ) -func tmpdir(t *testing.T, appliers ...fstest.Applier) (string, error) { +func tmpdir(t *testing.T, appliers ...fstest.Applier) string { + t.Helper() tmpdir := t.TempDir() - if err := fstest.Apply(appliers...).Apply(tmpdir); err != nil { - return "", err - } - return tmpdir, nil + err := fstest.Apply(appliers...).Apply(tmpdir) + require.NoError(t, err) + return tmpdir } func buildxCmd(sb integration.Sandbox, args ...string) *exec.Cmd {