... | ... |
@@ -1,7 +1,9 @@ |
1 | 1 |
package graph |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "github.com/dotcloud/docker/fake" |
|
4 |
+ "archive/tar" |
|
5 |
+ "bytes" |
|
6 |
+ "io" |
|
5 | 7 |
"io/ioutil" |
6 | 8 |
"os" |
7 | 9 |
"path" |
... | ... |
@@ -29,7 +31,7 @@ func TestInit(t *testing.T) { |
29 | 29 |
func TestCreate(t *testing.T) { |
30 | 30 |
graph := tempGraph(t) |
31 | 31 |
defer os.RemoveAll(graph.Root) |
32 |
- archive, err := fake.FakeTar() |
|
32 |
+ archive, err := fakeTar() |
|
33 | 33 |
if err != nil { |
34 | 34 |
t.Fatal(err) |
35 | 35 |
} |
... | ... |
@@ -53,7 +55,7 @@ func TestCreate(t *testing.T) { |
53 | 53 |
func TestRegister(t *testing.T) { |
54 | 54 |
graph := tempGraph(t) |
55 | 55 |
defer os.RemoveAll(graph.Root) |
56 |
- archive, err := fake.FakeTar() |
|
56 |
+ archive, err := fakeTar() |
|
57 | 57 |
if err != nil { |
58 | 58 |
t.Fatal(err) |
59 | 59 |
} |
... | ... |
@@ -86,7 +88,7 @@ func TestRegister(t *testing.T) { |
86 | 86 |
func TestMount(t *testing.T) { |
87 | 87 |
graph := tempGraph(t) |
88 | 88 |
defer os.RemoveAll(graph.Root) |
89 |
- archive, err := fake.FakeTar() |
|
89 |
+ archive, err := fakeTar() |
|
90 | 90 |
if err != nil { |
91 | 91 |
t.Fatal(err) |
92 | 92 |
} |
... | ... |
@@ -121,7 +123,7 @@ func TestMount(t *testing.T) { |
121 | 121 |
func TestDelete(t *testing.T) { |
122 | 122 |
graph := tempGraph(t) |
123 | 123 |
defer os.RemoveAll(graph.Root) |
124 |
- archive, err := fake.FakeTar() |
|
124 |
+ archive, err := fakeTar() |
|
125 | 125 |
if err != nil { |
126 | 126 |
t.Fatal(err) |
127 | 127 |
} |
... | ... |
@@ -183,9 +185,26 @@ func tempGraph(t *testing.T) *Graph { |
183 | 183 |
} |
184 | 184 |
|
185 | 185 |
func testArchive(t *testing.T) Archive { |
186 |
- archive, err := fake.FakeTar() |
|
186 |
+ archive, err := fakeTar() |
|
187 | 187 |
if err != nil { |
188 | 188 |
t.Fatal(err) |
189 | 189 |
} |
190 | 190 |
return archive |
191 | 191 |
} |
192 |
+ |
|
193 |
+func fakeTar() (io.Reader, error) { |
|
194 |
+ content := []byte("Hello world!\n") |
|
195 |
+ buf := new(bytes.Buffer) |
|
196 |
+ tw := tar.NewWriter(buf) |
|
197 |
+ for _, name := range []string{"/etc/postgres/postgres.conf", "/etc/passwd", "/var/log/postgres/postgres.conf"} { |
|
198 |
+ hdr := new(tar.Header) |
|
199 |
+ hdr.Size = int64(len(content)) |
|
200 |
+ hdr.Name = name |
|
201 |
+ if err := tw.WriteHeader(hdr); err != nil { |
|
202 |
+ return nil, err |
|
203 |
+ } |
|
204 |
+ tw.Write([]byte(content)) |
|
205 |
+ } |
|
206 |
+ tw.Close() |
|
207 |
+ return buf, nil |
|
208 |
+} |