-
Notifications
You must be signed in to change notification settings - Fork 18
/
harp_test.go
54 lines (52 loc) · 1.11 KB
/
harp_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
package main
import "testing"
func TestRetrieveServers(t *testing.T) {
cfg.Servers = map[string][]*Server{
"prod": {
&Server{
User: "app",
Host: "192.168.59.103",
Port: ":49153",
},
&Server{
User: "app",
Host: "192.168.59.103",
Port: ":49154",
},
},
"dev": {
&Server{
User: "app",
Host: "192.168.59.103",
Port: ":49155",
},
&Server{
User: "app",
Host: "192.168.59.103",
Port: ":49156",
},
},
}
option.serverSets = []string{"prod"}
option.servers = []string{"app@192.168.59.103:49156"}
servers := retrieveServers()
if len(servers) != 3 {
t.Error("failed to retrieve 3 correct servers")
}
for i, server := range servers {
switch i {
case 0:
if server.String() != "app@192.168.59.103:49153" {
t.Error("failed to retrieve server app@192.168.59.103:49153")
}
case 1:
if server.String() != "app@192.168.59.103:49154" {
t.Error("failed to retrieve server app@192.168.59.103:49154")
}
case 2:
if server.String() != "app@192.168.59.103:49156" {
t.Error("failed to retrieve server app@192.168.59.103:49156")
}
}
}
}