MCPcopy Index your code
hub / github.com/coder/coder / TestRename

Function TestRename

cli/rename_test.go:15–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestRename(t *testing.T) {
16 t.Parallel()
17
18 client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true, AllowWorkspaceRenames: true})
19 owner := coderdtest.CreateFirstUser(t, client)
20 member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
21 version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
22 coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
23 template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
24 workspace := coderdtest.CreateWorkspace(t, member, template.ID)
25 coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
26
27 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
28 defer cancel()
29
30 want := coderdtest.RandomUsername(t)
31 inv, root := clitest.New(t, "rename", workspace.Name, want, "--yes")
32 clitest.SetupConfig(t, member, root)
33 pty := ptytest.New(t)
34 pty.Attach(inv)
35 clitest.Start(t, inv)
36
37 pty.ExpectMatch("confirm rename:")
38 pty.WriteLine(workspace.Name)
39 pty.ExpectMatch("renamed to")
40
41 ws, err := client.Workspace(ctx, workspace.ID)
42 assert.NoError(t, err)
43
44 got := ws.Name
45 assert.Equal(t, want, got, "workspace name did not change")
46}

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateAnotherUserFunction · 0.92
CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
CreateWorkspaceFunction · 0.92
RandomUsernameFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
NewFunction · 0.92

Tested by

no test coverage detected