@@ -63,8 +63,11 @@ func setupWorkspaceForAgent(t *testing.T, mutations ...func([]*proto.Agent) []*p
6363 client , store := coderdtest .NewWithDatabase (t , nil )
6464 client .SetLogger (testutil .Logger (t ).Named ("client" ))
6565 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+ })
6769 r := dbfake .WorkspaceBuild (t , store , database.WorkspaceTable {
70+ Name : "myworkspace" ,
6871 OrganizationID : first .OrganizationID ,
6972 OwnerID : user .ID ,
7073 }).WithAgent (mutations ... ).Do ()
@@ -98,6 +101,46 @@ func TestSSH(t *testing.T) {
98101 pty .WriteLine ("exit" )
99102 <- cmdDone
100103 })
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+ })
101144 t .Run ("StartStoppedWorkspace" , func (t * testing.T ) {
102145 t .Parallel ()
103146
0 commit comments