Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 41c3c59

Browse files
committed
Adjust tests for changes in Go 1.12.8 / 1.11.13
For now, just verifying that an error is returned, but not checking the error message itself, because those are not under our control, and may change with different Go versions. ``` === Failed === FAIL: opts TestParseDockerDaemonHost (0.00s) hosts_test.go:87: tcp tcp:a.b.c.d address expected error "Invalid bind address format: tcp:a.b.c.d" return, got "parse tcp://tcp:a.b.c.d: invalid port \":a.b.c.d\" after host" and addr hosts_test.go:87: tcp tcp:a.b.c.d/path address expected error "Invalid bind address format: tcp:a.b.c.d/path" return, got "parse tcp://tcp:a.b.c.d/path: invalid port \":a.b.c.d\" after host" and addr === FAIL: opts TestParseTCP (0.00s) hosts_test.go:129: tcp tcp:a.b.c.d address expected error Invalid bind address format: tcp:a.b.c.d return, got parse tcp://tcp:a.b.c.d: invalid port ":a.b.c.d" after host and addr hosts_test.go:129: tcp tcp:a.b.c.d/path address expected error Invalid bind address format: tcp:a.b.c.d/path return, got parse tcp://tcp:a.b.c.d/path: invalid port ":a.b.c.d" after host and addr ``` Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit de1523d221d7e719fe470c63c3cd908092e772df) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 307befd7e23004f038e0231349ac9fb00f39c91d Component: cli
1 parent 5c1d8b6 commit 41c3c59

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

components/cli/opts/hosts_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func TestParseHost(t *testing.T) {
5353
func TestParseDockerDaemonHost(t *testing.T) {
5454
invalids := map[string]string{
5555

56-
"tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d",
57-
"tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path",
56+
"tcp:a.b.c.d": "",
57+
"tcp:a.b.c.d/path": "",
5858
"udp://127.0.0.1": "Invalid bind address format: udp://127.0.0.1",
5959
"udp://127.0.0.1:2375": "Invalid bind address format: udp://127.0.0.1:2375",
6060
"tcp://unix:///run/docker.sock": "Invalid proto, expected tcp: unix:///run/docker.sock",
@@ -83,7 +83,7 @@ func TestParseDockerDaemonHost(t *testing.T) {
8383
"localhost:5555/path": "tcp://localhost:5555/path",
8484
}
8585
for invalidAddr, expectedError := range invalids {
86-
if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || err.Error() != expectedError {
86+
if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || expectedError != "" && err.Error() != expectedError {
8787
t.Errorf("tcp %v address expected error %q return, got %q and addr %v", invalidAddr, expectedError, err, addr)
8888
}
8989
}
@@ -99,8 +99,8 @@ func TestParseTCP(t *testing.T) {
9999
defaultHTTPHost = "tcp://127.0.0.1:2376"
100100
)
101101
invalids := map[string]string{
102-
"tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d",
103-
"tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path",
102+
"tcp:a.b.c.d": "",
103+
"tcp:a.b.c.d/path": "",
104104
"udp://127.0.0.1": "Invalid proto, expected tcp: udp://127.0.0.1",
105105
"udp://127.0.0.1:2375": "Invalid proto, expected tcp: udp://127.0.0.1:2375",
106106
}
@@ -125,7 +125,7 @@ func TestParseTCP(t *testing.T) {
125125
"localhost:5555/path": "tcp://localhost:5555/path",
126126
}
127127
for invalidAddr, expectedError := range invalids {
128-
if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || err.Error() != expectedError {
128+
if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || expectedError != "" && err.Error() != expectedError {
129129
t.Errorf("tcp %v address expected error %v return, got %s and addr %v", invalidAddr, expectedError, err, addr)
130130
}
131131
}

0 commit comments

Comments
 (0)