2020-02-06 00:55:26 +00:00
|
|
|
package allregions
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-11-25 06:55:13 +00:00
|
|
|
"github.com/rs/zerolog"
|
2020-02-06 00:55:26 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEdgeDiscovery(t *testing.T) {
|
|
|
|
mockAddrs := newMockAddrs(19, 2, 5)
|
|
|
|
netLookupSRV = mockNetLookupSRV(mockAddrs)
|
|
|
|
netLookupIP = mockNetLookupIP(mockAddrs)
|
|
|
|
|
|
|
|
expectedAddrSet := map[string]bool{}
|
|
|
|
for _, addrs := range mockAddrs.addrMap {
|
|
|
|
for _, addr := range addrs {
|
|
|
|
expectedAddrSet[addr.String()] = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-25 06:55:13 +00:00
|
|
|
l := zerolog.Nop()
|
|
|
|
addrLists, err := edgeDiscovery(&l)
|
2020-02-06 00:55:26 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
actualAddrSet := map[string]bool{}
|
|
|
|
for _, addrs := range addrLists {
|
|
|
|
for _, addr := range addrs {
|
|
|
|
actualAddrSet[addr.String()] = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, expectedAddrSet, actualAddrSet)
|
|
|
|
}
|