Merge pull request #2377 from crazy-max/test-stdin

tests: build from stdin
This commit is contained in:
Tõnis Tiigi 2024-04-02 09:54:45 -07:00 committed by GitHub
commit 38fbd9a85c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 0 deletions

View File

@ -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,
@ -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))