Skip to content

Commit d0f47df

Browse files
committed
test: use integration.Tmpdir consistently
Signed-off-by: Justin Chadwell <[email protected]>
1 parent 659fba6 commit d0f47df

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

cmd/buildctl/build_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ import (
2323
)
2424

2525
func testBuildWithLocalFiles(t *testing.T, sb integration.Sandbox) {
26-
dir, err := tmpdir(
26+
dir := integration.Tmpdir(
2727
t,
2828
fstest.CreateFile("foo", []byte("bar"), 0600),
2929
)
30-
require.NoError(t, err)
3130

3231
st := llb.Image("busybox").
3332
Run(llb.Shlex("sh -c 'echo -n bar > foo2'")).
@@ -185,11 +184,3 @@ func marshal(ctx context.Context, st llb.State) (io.Reader, error) {
185184
}
186185
return bytes.NewBuffer(dt), nil
187186
}
188-
189-
func tmpdir(t *testing.T, appliers ...fstest.Applier) (string, error) {
190-
tmpdir := t.TempDir()
191-
if err := fstest.Apply(appliers...).Apply(tmpdir); err != nil {
192-
return "", err
193-
}
194-
return tmpdir, nil
195-
}

frontend/frontend_test.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ func testRefReadFile(t *testing.T, sb integration.Sandbox) {
6767

6868
testcontent := []byte(`foobar`)
6969

70-
dir, err := tmpdir(
70+
dir := integration.Tmpdir(
7171
t,
7272
fstest.CreateFile("test", testcontent, 0666),
7373
)
74-
require.NoError(t, err)
7574

7675
frontend := func(ctx context.Context, c gateway.Client) (*gateway.Result, error) {
7776
def, err := llb.Local("mylocal").Marshal(ctx)
@@ -130,7 +129,7 @@ func testRefReadDir(t *testing.T, sb integration.Sandbox) {
130129
require.NoError(t, err)
131130
defer c.Close()
132131

133-
dir, err := tmpdir(
132+
dir := integration.Tmpdir(
134133
t,
135134
fstest.CreateDir("somedir", 0777),
136135
fstest.CreateFile("somedir/foo1.txt", []byte(`foo1`), 0666),
@@ -139,7 +138,6 @@ func testRefReadDir(t *testing.T, sb integration.Sandbox) {
139138
fstest.Symlink("bar.log", "somedir/link.log"),
140139
fstest.CreateDir("somedir/baz.dir", 0777),
141140
)
142-
require.NoError(t, err)
143141

144142
expMap := make(map[string]*fstypes.Stat)
145143

@@ -248,11 +246,10 @@ func testRefStatFile(t *testing.T, sb integration.Sandbox) {
248246

249247
testcontent := []byte(`foobar`)
250248

251-
dir, err := tmpdir(
249+
dir := integration.Tmpdir(
252250
t,
253251
fstest.CreateFile("test", testcontent, 0666),
254252
)
255-
require.NoError(t, err)
256253

257254
exp, err := fsutil.Stat(filepath.Join(dir, "test"))
258255
require.NoError(t, err)
@@ -340,11 +337,3 @@ func testRefEvaluate(t *testing.T, sb integration.Sandbox) {
340337
_, err = c.Build(ctx, client.SolveOpt{}, "", frontend, nil)
341338
require.NoError(t, err)
342339
}
343-
344-
func tmpdir(t *testing.T, appliers ...fstest.Applier) (string, error) {
345-
tmpdir := t.TempDir()
346-
if err := fstest.Apply(appliers...).Apply(tmpdir); err != nil {
347-
return "", err
348-
}
349-
return tmpdir, nil
350-
}

0 commit comments

Comments
 (0)