mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
integration-cli/TestBuildAddTar: embed Dockerfile
Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
This commit is contained in:
parent
24c00c8508
commit
5d8e80ba8d
2 changed files with 16 additions and 26 deletions
|
@ -1,14 +0,0 @@
|
||||||
FROM busybox
|
|
||||||
ADD test.tar /
|
|
||||||
RUN cat /test/foo | grep Hi
|
|
||||||
ADD test.tar /test.tar
|
|
||||||
RUN cat /test.tar/test/foo | grep Hi
|
|
||||||
ADD test.tar /unlikely-to-exist
|
|
||||||
RUN cat /unlikely-to-exist/test/foo | grep Hi
|
|
||||||
ADD test.tar /unlikely-to-exist-trailing-slash/
|
|
||||||
RUN cat /unlikely-to-exist-trailing-slash/test/foo | grep Hi
|
|
||||||
RUN mkdir /existing-directory
|
|
||||||
ADD test.tar /existing-directory
|
|
||||||
RUN cat /existing-directory/test/foo | grep Hi
|
|
||||||
ADD test.tar /existing-directory-trailing-slash/
|
|
||||||
RUN cat /existing-directory-trailing-slash/test/foo | grep Hi
|
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -1752,6 +1751,21 @@ func TestBuildAddTar(t *testing.T) {
|
||||||
defer deleteImages(name)
|
defer deleteImages(name)
|
||||||
|
|
||||||
ctx := func() *FakeContext {
|
ctx := func() *FakeContext {
|
||||||
|
dockerfile := `
|
||||||
|
FROM busybox
|
||||||
|
ADD test.tar /
|
||||||
|
RUN cat /test/foo | grep Hi
|
||||||
|
ADD test.tar /test.tar
|
||||||
|
RUN cat /test.tar/test/foo | grep Hi
|
||||||
|
ADD test.tar /unlikely-to-exist
|
||||||
|
RUN cat /unlikely-to-exist/test/foo | grep Hi
|
||||||
|
ADD test.tar /unlikely-to-exist-trailing-slash/
|
||||||
|
RUN cat /unlikely-to-exist-trailing-slash/test/foo | grep Hi
|
||||||
|
RUN mkdir /existing-directory
|
||||||
|
ADD test.tar /existing-directory
|
||||||
|
RUN cat /existing-directory/test/foo | grep Hi
|
||||||
|
ADD test.tar /existing-directory-trailing-slash/
|
||||||
|
RUN cat /existing-directory-trailing-slash/test/foo | grep Hi`
|
||||||
tmpDir, err := ioutil.TempDir("", "fake-context")
|
tmpDir, err := ioutil.TempDir("", "fake-context")
|
||||||
testTar, err := os.Create(filepath.Join(tmpDir, "test.tar"))
|
testTar, err := os.Create(filepath.Join(tmpDir, "test.tar"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1774,19 +1788,9 @@ func TestBuildAddTar(t *testing.T) {
|
||||||
t.Fatalf("failed to close tar archive: %v", err)
|
t.Fatalf("failed to close tar archive: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dockerfile, err := os.Open(filepath.Join(workingDirectory, "build_tests", "TestBuildAddTar", "Dockerfile"))
|
if err := ioutil.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to open source dockerfile: %v", err)
|
|
||||||
}
|
|
||||||
defer dockerfile.Close()
|
|
||||||
dest, err := os.Create(filepath.Join(tmpDir, "Dockerfile"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to open destination dockerfile: %v", err)
|
t.Fatalf("failed to open destination dockerfile: %v", err)
|
||||||
}
|
}
|
||||||
if _, err := io.Copy(dest, dockerfile); err != nil {
|
|
||||||
t.Fatalf("failed top copy dockerfile: %v", err)
|
|
||||||
}
|
|
||||||
defer dest.Close()
|
|
||||||
return &FakeContext{Dir: tmpDir}
|
return &FakeContext{Dir: tmpDir}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue