From 0dcbed3f53148dfff5dee0d0d0c0044ca0d41a2d Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Tue, 27 Jun 2023 11:14:40 +0100 Subject: [PATCH] tests: add simple local bake test Signed-off-by: Justin Chadwell --- tests/bake.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/bake.go b/tests/bake.go index 130fb0bd..b76a8bb8 100644 --- a/tests/bake.go +++ b/tests/bake.go @@ -18,6 +18,7 @@ func bakeCmd(sb integration.Sandbox, opts ...cmdOpt) (string, error) { } var bakeTests = []func(t *testing.T, sb integration.Sandbox){ + testBakeLocal, testBakeRemote, testBakeRemoteCmdContext, testBakeRemoteCmdContextOverride, @@ -26,6 +27,29 @@ var bakeTests = []func(t *testing.T, sb integration.Sandbox){ testBakeRemoteCmdContextEscapeRelative, } +func testBakeLocal(t *testing.T, sb integration.Sandbox) { + dockerfile := []byte(` +FROM scratch +COPY foo /foo + `) + bakefile := []byte(` +target "default" { +} +`) + dir := tmpdir( + t, + fstest.CreateFile("docker-bake.hcl", bakefile, 0600), + fstest.CreateFile("Dockerfile", dockerfile, 0600), + fstest.CreateFile("foo", []byte("foo"), 0600), + ) + dirDest := t.TempDir() + + out, err := bakeCmd(sb, withDir(dir), withArgs("--set", "*.output=type=local,dest="+dirDest)) + require.NoError(t, err, out) + + require.FileExists(t, filepath.Join(dirDest, "foo")) +} + func testBakeRemote(t *testing.T, sb integration.Sandbox) { bakefile := []byte(` target "default" {