-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_test.go
58 lines (49 loc) · 1.07 KB
/
image_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
54
55
56
57
58
package containerd
import (
"runtime"
"testing"
"github.com/containerd/containerd/errdefs"
)
func TestImageIsUnpacked(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip()
}
const imageName = "docker.io/library/busybox:latest"
ctx, cancel := testContext()
defer cancel()
client, err := newClient(t, address)
if err != nil {
t.Fatal(err)
}
defer client.Close()
// Cleanup
err = client.ImageService().Delete(ctx, imageName)
if err != nil && !errdefs.IsNotFound(err) {
t.Fatal(err)
}
// By default pull does not unpack an image
image, err := client.Pull(ctx, imageName)
if err != nil {
t.Fatal(err)
}
// Check that image is not unpacked
unpacked, err := image.IsUnpacked(ctx, DefaultSnapshotter)
if err != nil {
t.Fatal(err)
}
if unpacked {
t.Fatalf("image should not be unpacked")
}
// Check that image is unpacked
err = image.Unpack(ctx, DefaultSnapshotter)
if err != nil {
t.Fatal(err)
}
unpacked, err = image.IsUnpacked(ctx, DefaultSnapshotter)
if err != nil {
t.Fatal(err)
}
if !unpacked {
t.Fatalf("image should be unpacked")
}
}