forked from genuinetools/img
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unpack_test.go
53 lines (41 loc) · 1.23 KB
/
unpack_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestUnpackFromBuild(t *testing.T) {
name := "testbuildunpack"
runBuild(t, name, withDockerfile(`
FROM busybox
RUN echo unpack
`))
tmpd, err := ioutil.TempDir("", "img-unpack")
if err != nil {
t.Fatalf("creating temporary directory for unpack failed: %v", err)
}
defer os.RemoveAll(tmpd)
rootfs := filepath.Join(tmpd, "rootfs")
run(t, "unpack", "-o", rootfs, name)
// Make sure the image actually is unpacked in the directory.
etc := filepath.Join(rootfs, "etc")
if _, err := os.Stat(etc); os.IsNotExist(err) {
t.Fatalf("expected etc directory at %q to exist but it did not", etc)
}
}
func TestUnpackFromPull(t *testing.T) {
run(t, "pull", "r.j3ss.co/stress")
tmpd, err := ioutil.TempDir("", "img-unpack")
if err != nil {
t.Fatalf("creating temporary directory for unpack failed: %v", err)
}
defer os.RemoveAll(tmpd)
rootfs := filepath.Join(tmpd, "rootfs")
run(t, "unpack", "-o", rootfs, "r.j3ss.co/stress")
// Make sure the image actually is unpacked in the directory.
etc := filepath.Join(rootfs, "etc")
if _, err := os.Stat(etc); os.IsNotExist(err) {
t.Fatalf("expected etc directory at %q to exist but it did not", etc)
}
}