31 lines
828 B
Go
31 lines
828 B
Go
package app
|
|
|
|
import "testing"
|
|
|
|
func TestIsContainerIfaceIncludesNetnsVeth(t *testing.T) {
|
|
cases := map[string]bool{
|
|
"docker0": true,
|
|
"br-abcdef123": true,
|
|
"veth123": true,
|
|
"svh6198e294": true,
|
|
"svn6198e294": true,
|
|
"eth0": false,
|
|
"tun0": false,
|
|
}
|
|
for iface, want := range cases {
|
|
if got := isContainerIface(iface); got != want {
|
|
t.Fatalf("isContainerIface(%q)=%v want=%v", iface, got, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestRouteLineIsLinkDown(t *testing.T) {
|
|
if !routeLineIsLinkDown("10.240.20.0/30 dev svh6a59db31 proto kernel scope link src 10.240.20.1 linkdown") {
|
|
t.Fatalf("expected linkdown route to be detected")
|
|
}
|
|
if routeLineIsLinkDown("10.240.20.0/30 dev svh6198e294 proto kernel scope link src 10.240.20.1") {
|
|
t.Fatalf("unexpected linkdown detection for active route")
|
|
}
|
|
}
|
|
|