36 lines
539 B
Go
36 lines
539 B
Go
package net
|
|
|
|
import (
|
|
"log"
|
|
"testing"
|
|
|
|
"git.loafle.net/overflow/overflow_discovery/net/model"
|
|
)
|
|
|
|
func TestScanZone(t *testing.T) {
|
|
endChan := make(chan bool)
|
|
zoneChan := make(chan *model.DiscoveryZone, 4)
|
|
logChan := make(chan error, 4)
|
|
|
|
defer func() {
|
|
close(endChan)
|
|
close(zoneChan)
|
|
close(logChan)
|
|
}()
|
|
|
|
go ScanZone(endChan, zoneChan, logChan)
|
|
|
|
Loop:
|
|
for {
|
|
select {
|
|
case zone := <-zoneChan:
|
|
log.Printf("zone: %v", zone)
|
|
case err := <-logChan:
|
|
log.Printf("log: %v", err)
|
|
case <-endChan:
|
|
break Loop
|
|
}
|
|
|
|
}
|
|
}
|