mirror of https://github.com/docker/docs.git
Rewrite TestContextTar tests to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
parent
51a56399f6
commit
d302d92961
|
@ -1,3 +0,0 @@
|
||||||
FROM busybox
|
|
||||||
ADD foo /foo
|
|
||||||
CMD ["cat", "/foo"]
|
|
|
@ -1 +0,0 @@
|
||||||
foo
|
|
|
@ -1414,20 +1414,31 @@ func TestBuildADDLocalAndRemoteFilesWithCache(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testContextTar(t *testing.T, compression archive.Compression) {
|
func testContextTar(t *testing.T, compression archive.Compression) {
|
||||||
contextDirectory := filepath.Join(workingDirectory, "build_tests", "TestContextTar")
|
ctx, err := fakeContext(
|
||||||
context, err := archive.Tar(contextDirectory, compression)
|
`FROM busybox
|
||||||
|
ADD foo /foo
|
||||||
|
CMD ["cat", "/foo"]`,
|
||||||
|
map[string]string{
|
||||||
|
"foo": "bar",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
defer ctx.Close()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
context, err := archive.Tar(ctx.Dir, compression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to build context tar: %v", err)
|
t.Fatalf("failed to build context tar: %v", err)
|
||||||
}
|
}
|
||||||
buildCmd := exec.Command(dockerBinary, "build", "-t", "contexttar", "-")
|
name := "contexttar"
|
||||||
|
buildCmd := exec.Command(dockerBinary, "build", "-t", name, "-")
|
||||||
|
defer deleteImages(name)
|
||||||
buildCmd.Stdin = context
|
buildCmd.Stdin = context
|
||||||
|
|
||||||
out, exitCode, err := runCommandWithOutput(buildCmd)
|
out, exitCode, err := runCommandWithOutput(buildCmd)
|
||||||
if err != nil || exitCode != 0 {
|
if err != nil || exitCode != 0 {
|
||||||
t.Fatalf("build failed to complete: %v %v", out, err)
|
t.Fatalf("build failed to complete: %v %v", out, err)
|
||||||
}
|
}
|
||||||
deleteImages("contexttar")
|
|
||||||
logDone(fmt.Sprintf("build - build an image with a context tar, compression: %v", compression))
|
logDone(fmt.Sprintf("build - build an image with a context tar, compression: %v", compression))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue