mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Tests for ADD tar
Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
This commit is contained in:
parent
4b1a464ac1
commit
cfa4999d69
5 changed files with 38 additions and 0 deletions
3
integration-cli/build_tests/TestBuildAddTar/1/Dockerfile
Normal file
3
integration-cli/build_tests/TestBuildAddTar/1/Dockerfile
Normal file
|
@ -0,0 +1,3 @@
|
|||
FROM busybox
|
||||
ADD test.tar /test.tar
|
||||
RUN cat /test.tar/test/foo
|
BIN
integration-cli/build_tests/TestBuildAddTar/1/test.tar
Normal file
BIN
integration-cli/build_tests/TestBuildAddTar/1/test.tar
Normal file
Binary file not shown.
3
integration-cli/build_tests/TestBuildAddTar/2/Dockerfile
Normal file
3
integration-cli/build_tests/TestBuildAddTar/2/Dockerfile
Normal file
|
@ -0,0 +1,3 @@
|
|||
FROM busybox
|
||||
ADD test.tar /
|
||||
RUN cat /test/foo
|
BIN
integration-cli/build_tests/TestBuildAddTar/2/test.tar
Normal file
BIN
integration-cli/build_tests/TestBuildAddTar/2/test.tar
Normal file
Binary file not shown.
|
@ -1731,3 +1731,35 @@ RUN [ "$(cat /testfile)" = 'test!' ]`
|
|||
}
|
||||
logDone("build - add and run script")
|
||||
}
|
||||
|
||||
func TestBuildAddTar(t *testing.T) {
|
||||
|
||||
checkOutput := func(out string) {
|
||||
n := -1
|
||||
x := ""
|
||||
for i, line := range strings.Split(out, "\n") {
|
||||
if strings.HasPrefix(line, "Step 2") {
|
||||
n = i + 2
|
||||
x = line[strings.Index(line, "cat ")+4:]
|
||||
}
|
||||
if i == n {
|
||||
if line != "Hi" {
|
||||
t.Fatalf("Could not find contents of %s (expected 'Hi' got '%s'", x, line)
|
||||
}
|
||||
n = -2
|
||||
}
|
||||
}
|
||||
if n > -2 {
|
||||
t.Fatalf("Could not find contents of %s in build output", x)
|
||||
}
|
||||
}
|
||||
|
||||
for _, n := range []string{"1", "2"} {
|
||||
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildAddTar", n)
|
||||
buildCmd := exec.Command(dockerBinary, "build", "-t", "testbuildaddtar", ".")
|
||||
buildCmd.Dir = buildDirectory
|
||||
out, _, err := runCommandWithOutput(buildCmd)
|
||||
errorOut(err, t, fmt.Sprintf("build failed to complete for TestBuildAddTar/%s: %v", n, err))
|
||||
checkOutput(out)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue