mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
Merge pull request #252 from picatz/test-network-net
Add more tests for network net
This commit is contained in:
commit
b6b064a5ef
1 changed files with 28 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue