-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
docker_test.go
41 lines (33 loc) · 945 Bytes
/
docker_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
package dockerimagesave
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPullImage(t *testing.T) {
err := PullImage("busybox:1.29.2")
assert.NoError(t, err)
}
func TestSaveImage(t *testing.T) {
err := SaveImage("busybox:1.29.2", "/tmp")
assert.NoError(t, err)
assert.FileExists(t, "/tmp/busybox_1.29.2.tar")
}
func TestImageExists(t *testing.T) {
exists, err := ImageExists("busybox:1.29.2")
assert.True(t, exists)
assert.NoError(t, err)
exists, err = ImageExists("nothing_here:latest")
assert.False(t, exists)
assert.NoError(t, err)
}
func TestImageExistsInRegistry(t *testing.T) {
exists, err := ImageExistsInRegistry("busybox:1.29.2")
assert.True(t, exists)
assert.NoError(t, err)
exists, err = ImageExistsInRegistry("guamulo/dockerimagesave:latest")
assert.True(t, exists)
assert.NoError(t, err)
exists, err = ImageExistsInRegistry("qweqwe:1")
assert.False(t, exists)
assert.NoError(t, err)
}