-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathnetcheck_test.go
More file actions
38 lines (29 loc) · 934 Bytes
/
netcheck_test.go
File metadata and controls
38 lines (29 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package cli_test
import (
"bytes"
"encoding/json"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/codersdk/healthsdk"
"github.com/coder/coder/v2/pty/ptytest"
)
func TestNetcheck(t *testing.T) {
t.Parallel()
pty := ptytest.New(t)
config := login(t, pty)
var out bytes.Buffer
inv, _ := clitest.New(t, "netcheck", "--global-config", string(config))
inv.Stdout = &out
clitest.StartWithWaiter(t, inv).RequireSuccess()
b := out.Bytes()
t.Log(string(b))
var report healthsdk.ClientNetcheckReport
require.NoError(t, json.Unmarshal(b, &report))
// We do not assert that the report is healthy, just that
// it has the expected number of reports per region.
require.Len(t, report.DERP.Regions, 1+1) // 1 built-in region + 1 test-managed STUN region
for _, v := range report.DERP.Regions {
require.Len(t, v.NodeReports, len(v.Region.Nodes))
}
}