forked from stojg/salio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
45 lines (36 loc) · 928 Bytes
/
main_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
package main
import (
"testing"
)
func TestFindCandidates(t *testing.T) {
bastion := &instance{
ID: "bastion1",
Name: "bastion1",
Role: "",
PublicIP: "",
PrivateIP: "",
IsNat: false,
Cluster: "cluster1",
}
server1 := &instance{
ID: "server1",
Name: "server1",
Role: "",
PublicIP: "",
PrivateIP: "",
IsNat: false,
Cluster: "cluster1",
Bastions: []*instance{bastion},
}
servers := []*instance{server1}
paths := getCandidates([]string{"server1"}, servers)
if len(paths) != 1 {
t.Errorf("Expected 1 jump path, got %d", len(paths))
}
if paths[0].Instance.Name != server1.Name {
t.Errorf("Expected candidate instance name to be %s, got %s", server1.Name, paths[0].Instance.Name)
}
if paths[0].Bastion.Name != bastion.Name {
t.Errorf("Expected candidate instance name to be %s, got %s", bastion.Name, paths[0].Bastion.Name)
}
}