@@ -7,7 +7,10 @@ import (
7
7
)
8
8
9
9
func TestDefaultEndpoint (t * testing.T ) {
10
- endpoint := getEndpoint ()
10
+ endpoint , err := getEndpoint ()
11
+ if err != nil {
12
+ t .Fatal ("%s" , err )
13
+ }
11
14
if endpoint != "unix:///var/run/docker.sock" {
12
15
t .Fatal ("Expected unix:///var/run/docker.sock" )
13
16
}
@@ -19,7 +22,11 @@ func TestDockerHostEndpoint(t *testing.T) {
19
22
t .Fatalf ("Unable to set DOCKER_HOST: %s" , err )
20
23
}
21
24
22
- endpoint := getEndpoint ()
25
+ endpoint , err := getEndpoint ()
26
+ if err != nil {
27
+ t .Fatal ("%s" , err )
28
+ }
29
+
23
30
if endpoint != "tcp://127.0.0.1:4243" {
24
31
t .Fatal ("Expected tcp://127.0.0.1:4243" )
25
32
}
@@ -39,8 +46,33 @@ func TestDockerFlagEndpoint(t *testing.T) {
39
46
t .Fatalf ("Unable to set endpoint flag: %s" , err )
40
47
}
41
48
42
- endpoint := getEndpoint ()
49
+ endpoint , err := getEndpoint ()
50
+ if err != nil {
51
+ t .Fatal ("%s" , err )
52
+ }
43
53
if endpoint != "tcp://127.0.0.1:5555" {
44
54
t .Fatal ("Expected tcp://127.0.0.1:5555" )
45
55
}
46
56
}
57
+
58
+ func TestUnixNotExists (t * testing.T ) {
59
+
60
+ endpoint = ""
61
+ err := os .Setenv ("DOCKER_HOST" , "unix:///does/not/exist" )
62
+ if err != nil {
63
+ t .Fatalf ("Unable to set DOCKER_HOST: %s" , err )
64
+ }
65
+
66
+ _ , err = getEndpoint ()
67
+ if err == nil {
68
+ t .Fatal ("endpoint should have failed" )
69
+ }
70
+ }
71
+
72
+ func TestUnixBadFormat (t * testing.T ) {
73
+ endpoint = "unix:/var/run/docker.sock"
74
+ _ , err := getEndpoint ()
75
+ if err == nil {
76
+ t .Fatal ("endpoint should have failed" )
77
+ }
78
+ }
0 commit comments