mirror of
https://github.com/bettercap/bettercap
synced 2025-07-30 11:40:33 -07:00
add test for EachHost
This commit is contained in:
parent
050eaaf6bc
commit
4b82e917c7
1 changed files with 16 additions and 0 deletions
|
@ -143,3 +143,19 @@ func TestHas(t *testing.T) {
|
|||
t.Error("unable find a known IP address in LAN struct")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEachHost(t *testing.T) {
|
||||
exampleBuffer := []string{}
|
||||
exampleLAN := buildExampleLAN()
|
||||
exampleEndpoint := buildExampleEndpoint()
|
||||
exampleLAN.hosts[exampleEndpoint.HwAddress] = exampleEndpoint
|
||||
exampleCB := func(mac string, e *Endpoint) {
|
||||
exampleBuffer = append(exampleBuffer, exampleEndpoint.HwAddress)
|
||||
}
|
||||
exampleLAN.EachHost(exampleCB)
|
||||
exp := 1
|
||||
got := len(exampleBuffer)
|
||||
if got != exp {
|
||||
t.Fatalf("expected '%d', got '%d'", exp, got)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue