mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
add test for NewLAN
This commit is contained in:
parent
9c4a43062c
commit
ba47e82e77
1 changed files with 26 additions and 0 deletions
|
@ -25,3 +25,29 @@ func buildExampleEndpoint() *Endpoint {
|
|||
foundEndpoint, _ := FindInterface(exampleIface.Name)
|
||||
return foundEndpoint
|
||||
}
|
||||
|
||||
func TestNewLAN(t *testing.T) {
|
||||
iface, err := FindInterface("")
|
||||
if err != nil {
|
||||
t.Error("no iface found", err)
|
||||
}
|
||||
gateway, err := FindGateway(iface)
|
||||
if err != nil {
|
||||
t.Error("no gateway found", err)
|
||||
}
|
||||
exNewCallback := func(e *Endpoint) {}
|
||||
exLostCallback := func(e *Endpoint) {}
|
||||
lan := NewLAN(iface, gateway, exNewCallback, exLostCallback)
|
||||
if lan.iface != iface {
|
||||
t.Fatalf("expected '%v', got '%v'", iface, lan.iface)
|
||||
}
|
||||
if lan.gateway != gateway {
|
||||
t.Fatalf("expected '%v', got '%v'", gateway, lan.gateway)
|
||||
}
|
||||
if len(lan.hosts) != 0 {
|
||||
t.Fatalf("expected '%v', got '%v'", 0, len(lan.hosts))
|
||||
}
|
||||
if !(len(lan.aliases.data) >= 0) {
|
||||
t.Fatalf("expected '%v', got '%v'", 0, len(lan.aliases.data))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue