(t *testing.T)
| 78 | } |
| 79 | |
| 80 | func TestSSH(t *testing.T) { |
| 81 | t.Parallel() |
| 82 | t.Run("ImmediateExit", func(t *testing.T) { |
| 83 | t.Parallel() |
| 84 | |
| 85 | client, workspace, agentToken := setupWorkspaceForAgent(t) |
| 86 | inv, root := clitest.New(t, "ssh", workspace.Name) |
| 87 | clitest.SetupConfig(t, client, root) |
| 88 | pty := ptytest.New(t).Attach(inv) |
| 89 | |
| 90 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 91 | defer cancel() |
| 92 | |
| 93 | cmdDone := tGo(t, func() { |
| 94 | err := inv.WithContext(ctx).Run() |
| 95 | assert.NoError(t, err) |
| 96 | }) |
| 97 | pty.ExpectMatch("Waiting") |
| 98 | |
| 99 | _ = agenttest.New(t, client.URL, agentToken) |
| 100 | coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID) |
| 101 | |
| 102 | // Shells on Mac, Windows, and Linux all exit shells with the "exit" command. |
| 103 | pty.WriteLine("exit") |
| 104 | <-cmdDone |
| 105 | }) |
| 106 | t.Run("WorkspaceNameInput", func(t *testing.T) { |
| 107 | t.Parallel() |
| 108 | |
| 109 | cases := []string{ |
| 110 | "myworkspace", |
| 111 | "myworkspace.dev", |
| 112 | "myuser/myworkspace", |
| 113 | "myuser--myworkspace", |
| 114 | "myuser/myworkspace--dev", |
| 115 | "myuser/myworkspace.dev", |
| 116 | "myuser--myworkspace--dev", |
| 117 | "myuser--myworkspace.dev", |
| 118 | "dev.myworkspace.myuser", |
| 119 | } |
| 120 | |
| 121 | for _, tc := range cases { |
| 122 | t.Run(tc, func(t *testing.T) { |
| 123 | t.Parallel() |
| 124 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 125 | defer cancel() |
| 126 | |
| 127 | client, workspace, agentToken := setupWorkspaceForAgent(t) |
| 128 | |
| 129 | inv, root := clitest.New(t, "ssh", tc) |
| 130 | clitest.SetupConfig(t, client, root) |
| 131 | pty := ptytest.New(t).Attach(inv) |
| 132 | |
| 133 | cmdDone := tGo(t, func() { |
| 134 | err := inv.WithContext(ctx).Run() |
| 135 | assert.NoError(t, err) |
| 136 | }) |
| 137 | pty.ExpectMatch("Waiting") |
nothing calls this directly
no test coverage detected