summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/hashicorp/memberlist/util_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-11-13 09:09:58 -0800
committerGitHub <noreply@github.com>2017-11-13 09:09:58 -0800
commit1329aa51b605cb54ba9aae3a82a0a87b881fb7b3 (patch)
tree93cbf354ab894a560fc2cef8ef685d681b4ff889 /vendor/github.com/hashicorp/memberlist/util_test.go
parent7304a61ef597970be3031b14e652fb3a4df44304 (diff)
downloadchat-1329aa51b605cb54ba9aae3a82a0a87b881fb7b3.tar.gz
chat-1329aa51b605cb54ba9aae3a82a0a87b881fb7b3.tar.bz2
chat-1329aa51b605cb54ba9aae3a82a0a87b881fb7b3.zip
Updating server dependancies. (#7816)
Diffstat (limited to 'vendor/github.com/hashicorp/memberlist/util_test.go')
-rw-r--r--vendor/github.com/hashicorp/memberlist/util_test.go41
1 files changed, 24 insertions, 17 deletions
diff --git a/vendor/github.com/hashicorp/memberlist/util_test.go b/vendor/github.com/hashicorp/memberlist/util_test.go
index e1d8eba01..b7f2b4199 100644
--- a/vendor/github.com/hashicorp/memberlist/util_test.go
+++ b/vendor/github.com/hashicorp/memberlist/util_test.go
@@ -7,24 +7,31 @@ import (
"time"
)
-func Test_hasPort(t *testing.T) {
- cases := []struct {
- s string
- expected bool
+func TestUtil_PortFunctions(t *testing.T) {
+ tests := []struct {
+ addr string
+ hasPort bool
+ ensurePort string
}{
- {"", false},
- {":80", true},
- {"127.0.0.1", false},
- {"127.0.0.1:80", true},
- {"::1", false},
- {"2001:db8:a0b:12f0::1", false},
- {"[2001:db8:a0b:12f0::1]", false},
- {"[2001:db8:a0b:12f0::1]:80", true},
- }
- for _, c := range cases {
- if hasPort(c.s) != c.expected {
- t.Fatalf("bad: '%s' hasPort was not %v", c.s, c.expected)
- }
+ {"1.2.3.4", false, "1.2.3.4:8301"},
+ {"1.2.3.4:1234", true, "1.2.3.4:1234"},
+ {"2600:1f14:e22:1501:f9a:2e0c:a167:67e8", false, "[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]:8301"},
+ {"[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]", false, "[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]:8301"},
+ {"[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]:1234", true, "[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]:1234"},
+ {"localhost", false, "localhost:8301"},
+ {"localhost:1234", true, "localhost:1234"},
+ {"hashicorp.com", false, "hashicorp.com:8301"},
+ {"hashicorp.com:1234", true, "hashicorp.com:1234"},
+ }
+ for _, tt := range tests {
+ t.Run(tt.addr, func(t *testing.T) {
+ if got, want := hasPort(tt.addr), tt.hasPort; got != want {
+ t.Fatalf("got %v want %v", got, want)
+ }
+ if got, want := ensurePort(tt.addr, 8301), tt.ensurePort; got != want {
+ t.Fatalf("got %v want %v", got, want)
+ }
+ })
}
}