github.com/aavshr/aws-sdk-go@v1.41.3/aws/csm/address_test.go (about) 1 //go:build go1.7 2 // +build go1.7 3 4 package csm 5 6 import "testing" 7 8 func TestAddressWithDefaults(t *testing.T) { 9 cases := map[string]struct { 10 Host, Port string 11 Expect string 12 }{ 13 "ip": { 14 Host: "127.0.0.2", Port: "", Expect: "127.0.0.2:31000", 15 }, 16 "localhost": { 17 Host: "localhost", Port: "", Expect: "127.0.0.1:31000", 18 }, 19 "uppercase localhost": { 20 Host: "LOCALHOST", Port: "", Expect: "127.0.0.1:31000", 21 }, 22 "port": { 23 Host: "localhost", Port: "32000", Expect: "127.0.0.1:32000", 24 }, 25 "ip6": { 26 Host: "::1", Port: "", Expect: "[::1]:31000", 27 }, 28 "unset": { 29 Host: "", Port: "", Expect: "127.0.0.1:31000", 30 }, 31 } 32 33 for name, c := range cases { 34 t.Run(name, func(t *testing.T) { 35 actual := AddressWithDefaults(c.Host, c.Port) 36 if e, a := c.Expect, actual; e != a { 37 t.Errorf("expect %v, got %v", e, a) 38 } 39 }) 40 } 41 }