cloudflare/cloudflared

Public

mirrored from https://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2021.10.4

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

edgediscovery/allregions/discovery_test.go

38lines · modecode

1package allregions
2
3import (
4 "fmt"
5 "testing"
6
7 "github.com/rs/zerolog"
8 "github.com/stretchr/testify/assert"
9)
10
11func (ea *EdgeAddr) String() string {
12 return fmt.Sprintf("%s-%s", ea.TCP, ea.UDP)
13}
14
15func TestEdgeDiscovery(t *testing.T) {
16 mockAddrs := newMockAddrs(19, 2, 5)
17 netLookupSRV = mockNetLookupSRV(mockAddrs)
18 netLookupIP = mockNetLookupIP(mockAddrs)
19
20 expectedAddrSet := map[string]bool{}
21 for _, addrs := range mockAddrs.addrMap {
22 for _, addr := range addrs {
23 expectedAddrSet[addr.String()] = true
24 }
25 }
26
27 l := zerolog.Nop()
28 addrLists, err := edgeDiscovery(&l, "")
29 assert.NoError(t, err)
30 actualAddrSet := map[string]bool{}
31 for _, addrs := range addrLists {
32 for _, addr := range addrs {
33 actualAddrSet[addr.String()] = true
34 }
35 }
36
37 assert.Equal(t, expectedAddrSet, actualAddrSet)
38}
39