@@ -7,7 +7,10 @@ import (
77)
88
99func TestDefaultEndpoint (t * testing.T ) {
10- endpoint := getEndpoint ()
10+ endpoint , err := getEndpoint ()
11+ if err != nil {
12+ t .Fatal ("%s" , err )
13+ }
1114 if endpoint != "unix:///var/run/docker.sock" {
1215 t .Fatal ("Expected unix:///var/run/docker.sock" )
1316 }
@@ -19,7 +22,11 @@ func TestDockerHostEndpoint(t *testing.T) {
1922 t .Fatalf ("Unable to set DOCKER_HOST: %s" , err )
2023 }
2124
22- endpoint := getEndpoint ()
25+ endpoint , err := getEndpoint ()
26+ if err != nil {
27+ t .Fatal ("%s" , err )
28+ }
29+
2330 if endpoint != "tcp://127.0.0.1:4243" {
2431 t .Fatal ("Expected tcp://127.0.0.1:4243" )
2532 }
@@ -39,8 +46,33 @@ func TestDockerFlagEndpoint(t *testing.T) {
3946 t .Fatalf ("Unable to set endpoint flag: %s" , err )
4047 }
4148
42- endpoint := getEndpoint ()
49+ endpoint , err := getEndpoint ()
50+ if err != nil {
51+ t .Fatal ("%s" , err )
52+ }
4353 if endpoint != "tcp://127.0.0.1:5555" {
4454 t .Fatal ("Expected tcp://127.0.0.1:5555" )
4555 }
4656}
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