-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollector_router_test.go
34 lines (31 loc) · 1.02 KB
/
collector_router_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
package main
import (
"net"
"testing"
hitron "github.com/hairyhenderson/hitron_coda"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
)
func TestRouterSysInfoLabels(t *testing.T) {
si := hitron.RouterSysInfo{
PrivLanIP: net.IPv4(192, 168, 0, 1),
PrivLanNet: &net.IPNet{Mask: net.IPv4Mask(255, 255, 255, 0)},
WanIP: []net.IP{net.IPv4(127, 200, 100, 10), net.ParseIP("2001:3::cafe:dead:beef")},
DNS: []net.IP{net.IPv4(127, 0, 0, 1), net.ParseIP("2001:3::2")},
RFMac: net.HardwareAddr{0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE},
RouterMode: "fancy!",
}
loc := hitron.RouterLocation{LocationText: "attic"}
expected := prometheus.Labels{
"lan_ip": "192.168.0.1/24",
"wan_ip4": "127.200.100.10",
"wan_ip6": "2001:3::cafe:dead:beef",
"dns4": "127.0.0.1",
"dns6": "2001:3::2",
"rf_mac": "de:ad:be:ef:ca:fe",
"router_mode": "fancy!",
"location": "attic",
}
out := routerSysInfoLabels(si, loc)
assert.Equal(t, expected, out)
}