forked from weaveworks/scope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theinternet_test.go
41 lines (38 loc) · 1.04 KB
/
theinternet_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
package render_test
import (
"reflect"
"testing"
"github.com/weaveworks/common/test"
"github.com/weaveworks/scope/render"
"github.com/weaveworks/scope/report"
)
func TestReportLocalNetworks(t *testing.T) {
r := report.MakeReport().Merge(report.Report{
Host: report.Topology{
Nodes: report.Nodes{
"nonets": report.MakeNode("nonets"),
"foo": report.MakeNode("foo").WithSets(report.MakeSets().
Add(report.HostLocalNetworks, report.MakeStringSet(
"10.0.0.1/8", "192.168.1.1/24", "10.0.0.1/8", "badnet/33")),
),
},
},
Overlay: report.Topology{
Nodes: report.Nodes{
"router": report.MakeNode("router").WithSets(report.MakeSets().
Add(report.HostLocalNetworks, report.MakeStringSet("10.32.0.1/12")),
),
},
},
})
want := report.MakeNetworks()
for _, cidr := range []string{"10.0.0.1/8", "192.168.1.1/24", "10.32.0.1/12"} {
if err := want.AddCIDR(cidr); err != nil {
panic(err)
}
}
have := render.LocalNetworks(r)
if !reflect.DeepEqual(want, have) {
t.Errorf("%s", test.Diff(want, have))
}
}