Merge pull request #252 from picatz/test-network-net

Add more tests for network net
This commit is contained in:
Simone Margaritelli 2018-05-01 16:19:33 +02:00 committed by GitHub
commit b6b064a5ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,3 +32,31 @@ func TestNormalizeMac(t *testing.T) {
t.Fatalf("expected '%s', got '%s'", exp, got)
}
}
// TODO: refactor to parse targets with an actual alias map
func TestParseTargets(t *testing.T) {
ips, macs, err := ParseTargets("192.168.1.2, 192.168.1.3", &Aliases{})
if err != nil {
t.Error("ips:", ips, "macs:", macs, "err:", err)
}
if len(ips) != 2 {
t.Fatalf("expected '%d', got '%d'", 2, len(ips))
}
if len(macs) != 0 {
t.Fatalf("expected '%d', got '%d'", 0, len(macs))
}
}
func TestBuildEndpointFromInterface(t *testing.T) {
ifaces, err := net.Interfaces()
if err != nil {
t.Error(err)
}
if len(ifaces) <= 0 {
t.Error("Unable to find any network interfaces to run test with.")
}
_, err = buildEndpointFromInterface(ifaces[0])
if err != nil {
t.Error(err)
}
}