(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func Test_ProxyCRUD(t *testing.T) { |
| 19 | t.Parallel() |
| 20 | |
| 21 | t.Run("Create", func(t *testing.T) { |
| 22 | t.Parallel() |
| 23 | |
| 24 | client, _ := coderdenttest.New(t, &coderdenttest.Options{ |
| 25 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 26 | Features: license.Features{ |
| 27 | codersdk.FeatureWorkspaceProxy: 1, |
| 28 | }, |
| 29 | }, |
| 30 | }) |
| 31 | |
| 32 | expectedName := "test-proxy" |
| 33 | ctx := testutil.Context(t, testutil.WaitLong) |
| 34 | inv, conf := newCLI( |
| 35 | t, |
| 36 | "wsproxy", "create", |
| 37 | "--name", expectedName, |
| 38 | "--display-name", "Test Proxy", |
| 39 | "--icon", "/emojis/1f4bb.png", |
| 40 | "--only-token", |
| 41 | ) |
| 42 | |
| 43 | pty := ptytest.New(t) |
| 44 | inv.Stdout = pty.Output() |
| 45 | clitest.SetupConfig(t, client, conf) //nolint:gocritic // create wsproxy requires owner |
| 46 | |
| 47 | err := inv.WithContext(ctx).Run() |
| 48 | require.NoError(t, err) |
| 49 | |
| 50 | line := pty.ReadLine(ctx) |
| 51 | parts := strings.Split(line, ":") |
| 52 | require.Len(t, parts, 2, "expected 2 parts") |
| 53 | _, err = uuid.Parse(parts[0]) |
| 54 | require.NoError(t, err, "expected token to be a uuid") |
| 55 | |
| 56 | // Fetch proxies and check output |
| 57 | inv, conf = newCLI( |
| 58 | t, |
| 59 | "wsproxy", "ls", |
| 60 | ) |
| 61 | |
| 62 | pty = ptytest.New(t) |
| 63 | inv.Stdout = pty.Output() |
| 64 | clitest.SetupConfig(t, client, conf) //nolint:gocritic // requires owner |
| 65 | |
| 66 | err = inv.WithContext(ctx).Run() |
| 67 | require.NoError(t, err) |
| 68 | pty.ExpectMatch(expectedName) |
| 69 | |
| 70 | // Also check via the api |
| 71 | proxies, err := client.WorkspaceProxies(ctx) //nolint:gocritic // requires owner |
| 72 | require.NoError(t, err, "failed to get workspace proxies") |
| 73 | // Include primary |
| 74 | require.Len(t, proxies.Regions, 2, "expected 1 proxy") |
| 75 | found := false |
nothing calls this directly
no test coverage detected