-
Notifications
You must be signed in to change notification settings - Fork 61
/
endpoint_test.go
69 lines (66 loc) · 1.42 KB
/
endpoint_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package sshtunnel_test
import (
"reflect"
"testing"
"github.com/elliotchance/sshtunnel"
)
func TestCreateEndpoint(t *testing.T) {
// these are test cases for which we expect no error to occur when
// constructing endpoints i.e. they should be correct
testCases := []struct {
input string
expectedEndpoint *sshtunnel.Endpoint
}{
{
"localhost:9000",
&sshtunnel.Endpoint{
Host: "localhost",
Port: 9000,
User: "",
},
},
{
&sshtunnel.Endpoint{
Host: "jumpbox.us-east-1.mydomain.com",
Port: 0,
User: "ec2-user",
},
},
{
"dqrsdfdssdfx.us-east-1.redshift.amazonaws.com:5439",
&sshtunnel.Endpoint{
Host: "dqrsdfdssdfx.us-east-1.redshift.amazonaws.com",
Port: 5439,
User: "",
},
},
{
"[email protected]:22", // IPv4 address
&sshtunnel.Endpoint{
Host: "1.2.3.4",
Port: 22,
User: "admin",
},
},
{
"admin@[2001:db8:1::ab9:C0A8:102]:22", // IPv6 address
&sshtunnel.Endpoint{
Host: "2001:db8:1::ab9:C0A8:102",
Port: 22,
User: "admin",
},
},
}
for i, tc := range testCases {
got, err := sshtunnel.NewEndpoint(tc.input)
if err != nil {
t.Errorf("unexpected error for correct input '%s': %v",
tc.input, err)
}
if !reflect.DeepEqual(got, tc.expectedEndpoint) {
t.Errorf("For test case %d, expected: %+v, got: %+v",
i, *tc.expectedEndpoint, *got)
}
}
}