Rewrite TestContextTar tests to not use fixtures

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
Alexandr Morozov 2014-09-24 16:55:52 +04:00
parent 51a56399f6
commit d302d92961
3 changed files with 16 additions and 9 deletions

View file

@ -1,3 +0,0 @@
FROM busybox
ADD foo /foo
CMD ["cat", "/foo"]

View file

@ -1 +0,0 @@
foo

View file

@ -1414,20 +1414,31 @@ func TestBuildADDLocalAndRemoteFilesWithCache(t *testing.T) {
}
func testContextTar(t *testing.T, compression archive.Compression) {
contextDirectory := filepath.Join(workingDirectory, "build_tests", "TestContextTar")
context, err := archive.Tar(contextDirectory, compression)
ctx, err := fakeContext(
`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 {
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
out, exitCode, err := runCommandWithOutput(buildCmd)
if err != nil || exitCode != 0 {
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))
}