@@ -63,8 +63,11 @@ func setupWorkspaceForAgent(t *testing.T, mutations ...func([]*proto.Agent) []*p
63
63
client , store := coderdtest .NewWithDatabase (t , nil )
64
64
client .SetLogger (testutil .Logger (t ).Named ("client" ))
65
65
first := coderdtest .CreateFirstUser (t , client )
66
- userClient , user := coderdtest .CreateAnotherUser (t , client , first .OrganizationID )
66
+ userClient , user := coderdtest .CreateAnotherUserMutators (t , client , first .OrganizationID , nil , func (r * codersdk.CreateUserRequestWithOrgs ) {
67
+ r .Username = "myuser"
68
+ })
67
69
r := dbfake .WorkspaceBuild (t , store , database.WorkspaceTable {
70
+ Name : "myworkspace" ,
68
71
OrganizationID : first .OrganizationID ,
69
72
OwnerID : user .ID ,
70
73
}).WithAgent (mutations ... ).Do ()
@@ -98,6 +101,46 @@ func TestSSH(t *testing.T) {
98
101
pty .WriteLine ("exit" )
99
102
<- cmdDone
100
103
})
104
+ t .Run ("WorkspaceNameInput" , func (t * testing.T ) {
105
+ t .Parallel ()
106
+
107
+ cases := []string {
108
+ "myworkspace" ,
109
+ "myuser/myworkspace" ,
110
+ "myuser--myworkspace" ,
111
+ "myuser/myworkspace--dev" ,
112
+ "myuser/myworkspace.dev" ,
113
+ "myuser--myworkspace--dev" ,
114
+ "myuser--myworkspace.dev" ,
115
+ }
116
+
117
+ for _ , tc := range cases {
118
+ t .Run (tc , func (t * testing.T ) {
119
+ t .Parallel ()
120
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
121
+ defer cancel ()
122
+
123
+ client , workspace , agentToken := setupWorkspaceForAgent (t )
124
+
125
+ inv , root := clitest .New (t , "ssh" , tc )
126
+ clitest .SetupConfig (t , client , root )
127
+ pty := ptytest .New (t ).Attach (inv )
128
+
129
+ cmdDone := tGo (t , func () {
130
+ err := inv .WithContext (ctx ).Run ()
131
+ assert .NoError (t , err )
132
+ })
133
+ pty .ExpectMatch ("Waiting" )
134
+
135
+ _ = agenttest .New (t , client .URL , agentToken )
136
+ coderdtest .AwaitWorkspaceAgents (t , client , workspace .ID )
137
+
138
+ // Shells on Mac, Windows, and Linux all exit shells with the "exit" command.
139
+ pty .WriteLine ("exit" )
140
+ <- cmdDone
141
+ })
142
+ }
143
+ })
101
144
t .Run ("StartStoppedWorkspace" , func (t * testing.T ) {
102
145
t .Parallel ()
103
146
0 commit comments