Files
coder/cli/netcheck_test.go
Kyle Carberry 22e781eced chore: add /v2 to import module path (#9072)
* chore: add /v2 to import module path

go mod requires semantic versioning with versions greater than 1.x

This was a mechanical update by running:
```
go install github.com/marwan-at-work/mod/cmd/mod@latest
mod upgrade
```

Migrate generated files to import /v2

* Fix gen
2023-08-18 18:55:43 +00:00

39 lines
872 B
Go

package cli_test
import (
"bytes"
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/healthcheck"
"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 healthcheck.DERPReport
require.NoError(t, json.Unmarshal(b, &report))
assert.True(t, report.Healthy)
require.Len(t, report.Regions, 1+5) // 1 built-in region + 5 STUN regions by default
for _, v := range report.Regions {
require.Len(t, v.NodeReports, len(v.Region.Nodes))
}
}