Skip to content

Commit

Permalink
tests: build from stdin
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Apr 2, 2024
1 parent 7dc5639 commit 7cded6b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func buildCmd(sb integration.Sandbox, opts ...cmdOpt) (string, error) {

var buildTests = []func(t *testing.T, sb integration.Sandbox){
testBuild,
testBuildStdin,
testImageIDOutput,
testBuildLocalExport,
testBuildRegistryExport,
Expand Down Expand Up @@ -65,6 +66,26 @@ func testBuild(t *testing.T, sb integration.Sandbox) {
require.NoError(t, err, string(out))
}

func testBuildStdin(t *testing.T, sb integration.Sandbox) {
dockerfile := []byte(`
FROM busybox:latest AS base
COPY foo /etc/foo
RUN cp /etc/foo /etc/bar
FROM scratch
COPY --from=base /etc/bar /bar
`)
dir := tmpdir(
t,
fstest.CreateFile("foo", []byte("foo"), 0600),
)

cmd := buildxCmd(sb, withDir(dir), withArgs("build", "--progress=quiet", "-f-", dir))
cmd.Stdin = bytes.NewReader(dockerfile)
out, err := cmd.CombinedOutput()
require.NoError(t, err, string(out))
}

func testBuildLocalExport(t *testing.T, sb integration.Sandbox) {
dir := createTestProject(t)
out, err := buildCmd(sb, withArgs(fmt.Sprintf("--output=type=local,dest=%s/result", dir), dir))
Expand Down

0 comments on commit 7cded6b

Please sign in to comment.