2017-10-20 09:09:07 +00:00
|
|
|
package net
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestScanZone(t *testing.T) {
|
2017-10-26 12:55:55 +00:00
|
|
|
dzc := &DiscoveryZoneConfig{
|
|
|
|
ExcludePatterns: []string{`^br-`, `^docker`},
|
|
|
|
}
|
|
|
|
zs := newZoneScan(dzc)
|
2017-10-20 09:09:07 +00:00
|
|
|
|
|
|
|
defer func() {
|
2017-10-26 12:55:55 +00:00
|
|
|
zs.Close()
|
2017-10-20 09:09:07 +00:00
|
|
|
}()
|
|
|
|
|
2017-10-26 12:55:55 +00:00
|
|
|
go scanZone(zs)
|
2017-10-20 09:09:07 +00:00
|
|
|
|
|
|
|
Loop:
|
|
|
|
for {
|
|
|
|
select {
|
2017-10-26 12:55:55 +00:00
|
|
|
case zone := <-zs.zoneChan:
|
|
|
|
|
|
|
|
t.Logf("zone: %v", zone)
|
|
|
|
case err := <-zs.logChan:
|
|
|
|
t.Logf("log: %v", err)
|
|
|
|
case <-zs.endChan:
|
2017-10-20 09:09:07 +00:00
|
|
|
break Loop
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|