mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
tests: build from stdin
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
7dc5639216
commit
7cded6b33b
@ -36,6 +36,7 @@ func buildCmd(sb integration.Sandbox, opts ...cmdOpt) (string, error) {
|
|||||||
|
|
||||||
var buildTests = []func(t *testing.T, sb integration.Sandbox){
|
var buildTests = []func(t *testing.T, sb integration.Sandbox){
|
||||||
testBuild,
|
testBuild,
|
||||||
|
testBuildStdin,
|
||||||
testImageIDOutput,
|
testImageIDOutput,
|
||||||
testBuildLocalExport,
|
testBuildLocalExport,
|
||||||
testBuildRegistryExport,
|
testBuildRegistryExport,
|
||||||
@ -65,6 +66,26 @@ func testBuild(t *testing.T, sb integration.Sandbox) {
|
|||||||
require.NoError(t, err, string(out))
|
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) {
|
func testBuildLocalExport(t *testing.T, sb integration.Sandbox) {
|
||||||
dir := createTestProject(t)
|
dir := createTestProject(t)
|
||||||
out, err := buildCmd(sb, withArgs(fmt.Sprintf("--output=type=local,dest=%s/result", dir), dir))
|
out, err := buildCmd(sb, withArgs(fmt.Sprintf("--output=type=local,dest=%s/result", dir), dir))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user