-
Notifications
You must be signed in to change notification settings - Fork 23
/
dockerRemote_test.go
53 lines (48 loc) · 1.09 KB
/
dockerRemote_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 collector
import (
"fmt"
"testing"
config "github.com/banyanops/collector/config"
)
func TestListDanglingImages(t *testing.T) {
fmt.Println("ListDanglingImages")
var err error
DockerClient, err = NewDockerClient(DOCKERPROTO, DOCKERADDR)
if err != nil {
t.Fatal(err)
}
imageList, err := ListDanglingImages()
if err != nil {
t.Fatal(err)
}
for _, image := range imageList {
fmt.Printf("image ID %s\n", string(image))
}
}
func TestRemoveImageByID(t *testing.T) {
var err error
DockerClient, err = NewDockerClient(DOCKERPROTO, DOCKERADDR)
if err != nil {
t.Fatal(err)
}
RegistrySpec = config.DockerHub
RegistryAPIURL, HubAPI, BasicAuth, XRegistryAuth = GetRegistryURL()
metadata := ImageMetadataInfo{
OtherMetadata: OtherMetadata{
Repo: "banyanops/nginx",
Tag: "1.7",
},
}
fmt.Println("TestPullImage %v", metadata)
PullImage(&metadata)
id := "d052f9300189"
resp, err := RemoveImageByID(ImageIDType(id))
if err != nil {
id = "bb65d19fc17c"
resp, err = RemoveImageByID(ImageIDType(id))
if err != nil {
t.Fatal(err)
}
}
fmt.Println(string(resp))
}