mirror of
https://github.com/coder/coder.git
synced 2026-06-05 05:58:20 +00:00
7d7cc27581
Closes [coder/internal#1400](https://github.com/coder/internal/issues/1400) Final batch of refactored CLI tests to avoid creating PTYs.
39 lines
957 B
Go
39 lines
957 B
Go
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/testutil"
|
|
)
|
|
|
|
func TestNetcheck(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
ctx := testutil.Context(t, testutil.WaitMedium)
|
|
config := login(ctx, t)
|
|
|
|
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))
|
|
}
|
|
}
|