github.com/mponton/terratest@v0.44.0/modules/ssh/session_test.go (about) 1 package ssh 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func TestSshConnectionOptions_ConnectionString(t *testing.T) { 10 type fields struct { 11 Address string 12 Port int 13 } 14 tests := []struct { 15 name string 16 fields fields 17 want string 18 }{ 19 { 20 name: "plain ipv4", 21 fields: fields{ 22 Address: "192.168.86.68", 23 Port: 22, 24 }, 25 want: "192.168.86.68:22", 26 }, 27 { 28 name: "plain ipv6", 29 fields: fields{ 30 Address: "2001:0db8:85a3:0000:0000:8a2e:0370:7334", 31 Port: 22, 32 }, 33 want: "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:22", 34 }, 35 { 36 name: "host fqdn", 37 fields: fields{ 38 Address: "host.for.test.com", 39 Port: 443, 40 }, 41 want: "host.for.test.com:443", 42 }, 43 } 44 for _, tt := range tests { 45 t.Run(tt.name, func(t *testing.T) { 46 options := &SshConnectionOptions{ 47 Address: tt.fields.Address, 48 Port: tt.fields.Port, 49 } 50 got := options.ConnectionString() 51 require.Equal(t, tt.want, got) 52 }) 53 } 54 }