Skip to content

Commit

Permalink
test: add unit-test for proxy/has port (#1668)
Browse files Browse the repository at this point in the history
add unit test for function hasPort
  • Loading branch information
mengjiahao authored and allencloud committed Jul 10, 2018
1 parent e1afb7a commit 6a76982
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion ctrd/image_proxy_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,29 @@ package ctrd
import "testing"

func TestHasPort(t *testing.T) {
// TODO
s := "127.0.0.1:80"
has := hasPort(s)
if has != true {
t.Fatalf("expect host:port %s has port, but return false", s)
}

s = "[FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::127.0.0.1]:80"
has = hasPort(s)
if has != true {
t.Fatalf("expect [ipv6::address]:port %s has port, but return false", s)
}

s = "127.0.0.1"
has = hasPort(s)
if has == true {
t.Fatalf("expect host %s has not port, but return true", s)
}

s = "[FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::127.0.0.1]"
has = hasPort(s)
if has == true {
t.Fatalf("expect [ipv6::address]:port %s has not port, but return true", s)
}
}

func TestCanonicalAddr(t *testing.T) {
Expand Down

0 comments on commit 6a76982

Please sign in to comment.