Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
Johan Euphrosine authored on 2014/07/22 07:02:311 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,14 +0,0 @@ |
1 |
-FROM busybox |
|
2 |
-ADD test.tar / |
|
3 |
-RUN cat /test/foo | grep Hi |
|
4 |
-ADD test.tar /test.tar |
|
5 |
-RUN cat /test.tar/test/foo | grep Hi |
|
6 |
-ADD test.tar /unlikely-to-exist |
|
7 |
-RUN cat /unlikely-to-exist/test/foo | grep Hi |
|
8 |
-ADD test.tar /unlikely-to-exist-trailing-slash/ |
|
9 |
-RUN cat /unlikely-to-exist-trailing-slash/test/foo | grep Hi |
|
10 |
-RUN mkdir /existing-directory |
|
11 |
-ADD test.tar /existing-directory |
|
12 |
-RUN cat /existing-directory/test/foo | grep Hi |
|
13 |
-ADD test.tar /existing-directory-trailing-slash/ |
|
14 |
-RUN cat /existing-directory-trailing-slash/test/foo | grep Hi |
... | ... |
@@ -3,7 +3,6 @@ package main |
3 | 3 |
import ( |
4 | 4 |
"archive/tar" |
5 | 5 |
"fmt" |
6 |
- "io" |
|
7 | 6 |
"io/ioutil" |
8 | 7 |
"os" |
9 | 8 |
"os/exec" |
... | ... |
@@ -1752,6 +1751,21 @@ func TestBuildAddTar(t *testing.T) { |
1752 | 1752 |
defer deleteImages(name) |
1753 | 1753 |
|
1754 | 1754 |
ctx := func() *FakeContext { |
1755 |
+ dockerfile := ` |
|
1756 |
+FROM busybox |
|
1757 |
+ADD test.tar / |
|
1758 |
+RUN cat /test/foo | grep Hi |
|
1759 |
+ADD test.tar /test.tar |
|
1760 |
+RUN cat /test.tar/test/foo | grep Hi |
|
1761 |
+ADD test.tar /unlikely-to-exist |
|
1762 |
+RUN cat /unlikely-to-exist/test/foo | grep Hi |
|
1763 |
+ADD test.tar /unlikely-to-exist-trailing-slash/ |
|
1764 |
+RUN cat /unlikely-to-exist-trailing-slash/test/foo | grep Hi |
|
1765 |
+RUN mkdir /existing-directory |
|
1766 |
+ADD test.tar /existing-directory |
|
1767 |
+RUN cat /existing-directory/test/foo | grep Hi |
|
1768 |
+ADD test.tar /existing-directory-trailing-slash/ |
|
1769 |
+RUN cat /existing-directory-trailing-slash/test/foo | grep Hi` |
|
1755 | 1770 |
tmpDir, err := ioutil.TempDir("", "fake-context") |
1756 | 1771 |
testTar, err := os.Create(filepath.Join(tmpDir, "test.tar")) |
1757 | 1772 |
if err != nil { |
... | ... |
@@ -1774,19 +1788,9 @@ func TestBuildAddTar(t *testing.T) { |
1774 | 1774 |
t.Fatalf("failed to close tar archive: %v", err) |
1775 | 1775 |
} |
1776 | 1776 |
|
1777 |
- dockerfile, err := os.Open(filepath.Join(workingDirectory, "build_tests", "TestBuildAddTar", "Dockerfile")) |
|
1778 |
- if err != nil { |
|
1779 |
- t.Fatalf("failed to open source dockerfile: %v", err) |
|
1780 |
- } |
|
1781 |
- defer dockerfile.Close() |
|
1782 |
- dest, err := os.Create(filepath.Join(tmpDir, "Dockerfile")) |
|
1783 |
- if err != nil { |
|
1777 |
+ if err := ioutil.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil { |
|
1784 | 1778 |
t.Fatalf("failed to open destination dockerfile: %v", err) |
1785 | 1779 |
} |
1786 |
- if _, err := io.Copy(dest, dockerfile); err != nil { |
|
1787 |
- t.Fatalf("failed top copy dockerfile: %v", err) |
|
1788 |
- } |
|
1789 |
- defer dest.Close() |
|
1790 | 1780 |
return &FakeContext{Dir: tmpDir} |
1791 | 1781 |
}() |
1792 | 1782 |
|