mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
Rollback https://github.com/coder/coder/pull/18081
This commit is contained in:
@@ -1027,8 +1027,8 @@ func (r *RootCmd) scaletestWorkspaceTraffic() *serpent.Command {
|
||||
BytesPerTick: bytesPerTick,
|
||||
Duration: strategy.timeout,
|
||||
TickInterval: tickInterval,
|
||||
ReadMetrics: metrics.ReadMetrics(ws.OwnerUsername, ws.Name, agent.Name),
|
||||
WriteMetrics: metrics.WriteMetrics(ws.OwnerUsername, ws.Name, agent.Name),
|
||||
ReadMetrics: metrics.ReadMetrics(ws.OwnerName, ws.Name, agent.Name),
|
||||
WriteMetrics: metrics.WriteMetrics(ws.OwnerName, ws.Name, agent.Name),
|
||||
SSH: ssh,
|
||||
Echo: ssh,
|
||||
App: appConfig,
|
||||
@@ -1420,7 +1420,7 @@ func isScaleTestUser(user codersdk.User) bool {
|
||||
}
|
||||
|
||||
func isScaleTestWorkspace(workspace codersdk.Workspace) bool {
|
||||
return strings.HasPrefix(workspace.OwnerUsername, "scaletest-") ||
|
||||
return strings.HasPrefix(workspace.OwnerName, "scaletest-") ||
|
||||
strings.HasPrefix(workspace.Name, "scaletest-")
|
||||
}
|
||||
|
||||
@@ -1592,7 +1592,7 @@ func createWorkspaceAppConfig(client *codersdk.Client, appHost, app string, work
|
||||
|
||||
c.URL = fmt.Sprintf("%s://%s", client.URL.Scheme, strings.Replace(appHost, "*", agent.Apps[i].SubdomainName, 1))
|
||||
} else {
|
||||
c.URL = fmt.Sprintf("%s/@%s/%s.%s/apps/%s", client.URL.String(), workspace.OwnerUsername, workspace.Name, agent.Name, agent.Apps[i].Slug)
|
||||
c.URL = fmt.Sprintf("%s/@%s/%s.%s/apps/%s", client.URL.String(), workspace.OwnerName, workspace.Name, agent.Name, agent.Apps[i].Slug)
|
||||
}
|
||||
|
||||
return c, nil
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace)
|
||||
if workspace.Favorite {
|
||||
favIco = "★"
|
||||
}
|
||||
workspaceName := favIco + " " + workspace.OwnerUsername + "/" + workspace.Name
|
||||
workspaceName := favIco + " " + workspace.OwnerName + "/" + workspace.Name
|
||||
return workspaceListRow{
|
||||
Favorite: workspace.Favorite,
|
||||
Workspace: workspace,
|
||||
|
||||
+4
-4
@@ -403,7 +403,7 @@ func buildVSCodeWorkspaceLink(
|
||||
) (*url.URL, url.Values) {
|
||||
qp := url.Values{}
|
||||
qp.Add("url", clientURL)
|
||||
qp.Add("owner", workspace.OwnerUsername)
|
||||
qp.Add("owner", workspace.OwnerName)
|
||||
qp.Add("workspace", workspace.Name)
|
||||
qp.Add("agent", workspaceAgent.Name)
|
||||
|
||||
@@ -435,7 +435,7 @@ func buildVSCodeWorkspaceDevContainerLink(
|
||||
|
||||
qp := url.Values{}
|
||||
qp.Add("url", clientURL)
|
||||
qp.Add("owner", workspace.OwnerUsername)
|
||||
qp.Add("owner", workspace.OwnerName)
|
||||
qp.Add("workspace", workspace.Name)
|
||||
qp.Add("agent", workspaceAgent.Name)
|
||||
qp.Add("devContainerName", containerName)
|
||||
@@ -596,7 +596,7 @@ func buildAppLinkURL(baseURL *url.URL, workspace codersdk.Workspace, agent coder
|
||||
u.Path = fmt.Sprintf(
|
||||
"%s/@%s/%s.%s/apps/%s/",
|
||||
preferredPathBase,
|
||||
workspace.OwnerUsername,
|
||||
workspace.OwnerName,
|
||||
workspace.Name,
|
||||
agent.Name,
|
||||
url.PathEscape(app.Slug),
|
||||
@@ -606,7 +606,7 @@ func buildAppLinkURL(baseURL *url.URL, workspace codersdk.Workspace, agent coder
|
||||
u.Path = fmt.Sprintf(
|
||||
"%s/@%s/%s.%s/terminal",
|
||||
preferredPathBase,
|
||||
workspace.OwnerUsername,
|
||||
workspace.OwnerName,
|
||||
workspace.Name,
|
||||
agent.Name,
|
||||
)
|
||||
|
||||
@@ -91,8 +91,8 @@ func Test_buildAppLinkURL(t *testing.T) {
|
||||
name: "without subdomain",
|
||||
baseURL: "https://coder.tld",
|
||||
workspace: codersdk.Workspace{
|
||||
Name: "Test-Workspace",
|
||||
OwnerUsername: "username",
|
||||
Name: "Test-Workspace",
|
||||
OwnerName: "username",
|
||||
},
|
||||
agent: codersdk.WorkspaceAgent{
|
||||
Name: "a-workspace-agent",
|
||||
@@ -108,8 +108,8 @@ func Test_buildAppLinkURL(t *testing.T) {
|
||||
name: "with command",
|
||||
baseURL: "https://coder.tld",
|
||||
workspace: codersdk.Workspace{
|
||||
Name: "Test-Workspace",
|
||||
OwnerUsername: "username",
|
||||
Name: "Test-Workspace",
|
||||
OwnerName: "username",
|
||||
},
|
||||
agent: codersdk.WorkspaceAgent{
|
||||
Name: "a-workspace-agent",
|
||||
@@ -123,8 +123,8 @@ func Test_buildAppLinkURL(t *testing.T) {
|
||||
name: "with subdomain",
|
||||
baseURL: "ftps://coder.tld",
|
||||
workspace: codersdk.Workspace{
|
||||
Name: "Test-Workspace",
|
||||
OwnerUsername: "username",
|
||||
Name: "Test-Workspace",
|
||||
OwnerName: "username",
|
||||
},
|
||||
agent: codersdk.WorkspaceAgent{
|
||||
Name: "a-workspace-agent",
|
||||
@@ -141,8 +141,8 @@ func Test_buildAppLinkURL(t *testing.T) {
|
||||
name: "with subdomain, but not apps host",
|
||||
baseURL: "https://coder.tld",
|
||||
workspace: codersdk.Workspace{
|
||||
Name: "Test-Workspace",
|
||||
OwnerUsername: "username",
|
||||
Name: "Test-Workspace",
|
||||
OwnerName: "username",
|
||||
},
|
||||
agent: codersdk.WorkspaceAgent{
|
||||
Name: "a-workspace-agent",
|
||||
|
||||
+2
-2
@@ -342,7 +342,7 @@ func TestRestartWithParameters(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
require.NoError(t, err)
|
||||
actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID)
|
||||
require.NoError(t, err)
|
||||
@@ -393,7 +393,7 @@ func TestRestartWithParameters(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
require.NoError(t, err)
|
||||
actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
+1
-1
@@ -327,7 +327,7 @@ func scheduleListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) s
|
||||
}
|
||||
}
|
||||
return scheduleListRow{
|
||||
WorkspaceName: workspace.OwnerUsername + "/" + workspace.Name,
|
||||
WorkspaceName: workspace.OwnerName + "/" + workspace.Name,
|
||||
StartsAt: autostartDisplay,
|
||||
StartsNext: nextStartDisplay,
|
||||
StopsAfter: autostopDisplay,
|
||||
|
||||
+29
-29
@@ -71,8 +71,8 @@ func setupTestSchedule(t *testing.T, sched *cron.Schedule) (ownerClient, memberC
|
||||
// Ensure same order as in CLI output
|
||||
ws = resp.Workspaces
|
||||
sort.Slice(ws, func(i, j int) bool {
|
||||
a := ws[i].OwnerUsername + "/" + ws[i].Name
|
||||
b := ws[j].OwnerUsername + "/" + ws[j].Name
|
||||
a := ws[i].OwnerName + "/" + ws[i].Name
|
||||
b := ws[j].OwnerName + "/" + ws[j].Name
|
||||
return a < b
|
||||
})
|
||||
|
||||
@@ -102,13 +102,13 @@ func TestScheduleShow(t *testing.T) {
|
||||
|
||||
// Then: they should see their own workspaces.
|
||||
// 1st workspace: a-owner-ws1 has both autostart and autostop enabled.
|
||||
pty.ExpectMatch(ws[0].OwnerUsername + "/" + ws[0].Name)
|
||||
pty.ExpectMatch(ws[0].OwnerName + "/" + ws[0].Name)
|
||||
pty.ExpectMatch(sched.Humanize())
|
||||
pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339))
|
||||
pty.ExpectMatch("8h")
|
||||
pty.ExpectMatch(ws[0].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339))
|
||||
// 2nd workspace: b-owner-ws2 has only autostart enabled.
|
||||
pty.ExpectMatch(ws[1].OwnerUsername + "/" + ws[1].Name)
|
||||
pty.ExpectMatch(ws[1].OwnerName + "/" + ws[1].Name)
|
||||
pty.ExpectMatch(sched.Humanize())
|
||||
pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339))
|
||||
})
|
||||
@@ -123,21 +123,21 @@ func TestScheduleShow(t *testing.T) {
|
||||
|
||||
// Then: they should see all workspaces
|
||||
// 1st workspace: a-owner-ws1 has both autostart and autostop enabled.
|
||||
pty.ExpectMatch(ws[0].OwnerUsername + "/" + ws[0].Name)
|
||||
pty.ExpectMatch(ws[0].OwnerName + "/" + ws[0].Name)
|
||||
pty.ExpectMatch(sched.Humanize())
|
||||
pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339))
|
||||
pty.ExpectMatch("8h")
|
||||
pty.ExpectMatch(ws[0].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339))
|
||||
// 2nd workspace: b-owner-ws2 has only autostart enabled.
|
||||
pty.ExpectMatch(ws[1].OwnerUsername + "/" + ws[1].Name)
|
||||
pty.ExpectMatch(ws[1].OwnerName + "/" + ws[1].Name)
|
||||
pty.ExpectMatch(sched.Humanize())
|
||||
pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339))
|
||||
// 3rd workspace: c-member-ws3 has only autostop enabled.
|
||||
pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name)
|
||||
pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name)
|
||||
pty.ExpectMatch("8h")
|
||||
pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339))
|
||||
// 4th workspace: d-member-ws4 has neither autostart nor autostop enabled.
|
||||
pty.ExpectMatch(ws[3].OwnerUsername + "/" + ws[3].Name)
|
||||
pty.ExpectMatch(ws[3].OwnerName + "/" + ws[3].Name)
|
||||
})
|
||||
|
||||
t.Run("OwnerSearchByName", func(t *testing.T) {
|
||||
@@ -150,14 +150,14 @@ func TestScheduleShow(t *testing.T) {
|
||||
|
||||
// Then: they should see workspaces matching that query
|
||||
// 2nd workspace: b-owner-ws2 has only autostart enabled.
|
||||
pty.ExpectMatch(ws[1].OwnerUsername + "/" + ws[1].Name)
|
||||
pty.ExpectMatch(ws[1].OwnerName + "/" + ws[1].Name)
|
||||
pty.ExpectMatch(sched.Humanize())
|
||||
pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339))
|
||||
})
|
||||
|
||||
t.Run("OwnerOneArg", func(t *testing.T) {
|
||||
// When: owner asks for a specific workspace by name
|
||||
inv, root := clitest.New(t, "schedule", "show", ws[2].OwnerUsername+"/"+ws[2].Name)
|
||||
inv, root := clitest.New(t, "schedule", "show", ws[2].OwnerName+"/"+ws[2].Name)
|
||||
//nolint:gocritic // Testing that owner user sees all
|
||||
clitest.SetupConfig(t, ownerClient, root)
|
||||
pty := ptytest.New(t).Attach(inv)
|
||||
@@ -165,7 +165,7 @@ func TestScheduleShow(t *testing.T) {
|
||||
|
||||
// Then: they should see that workspace
|
||||
// 3rd workspace: c-member-ws3 has only autostop enabled.
|
||||
pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name)
|
||||
pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name)
|
||||
pty.ExpectMatch("8h")
|
||||
pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339))
|
||||
})
|
||||
@@ -179,11 +179,11 @@ func TestScheduleShow(t *testing.T) {
|
||||
|
||||
// Then: they should see their own workspaces
|
||||
// 1st workspace: c-member-ws3 has only autostop enabled.
|
||||
pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name)
|
||||
pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name)
|
||||
pty.ExpectMatch("8h")
|
||||
pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339))
|
||||
// 2nd workspace: d-member-ws4 has neither autostart nor autostop enabled.
|
||||
pty.ExpectMatch(ws[3].OwnerUsername + "/" + ws[3].Name)
|
||||
pty.ExpectMatch(ws[3].OwnerName + "/" + ws[3].Name)
|
||||
})
|
||||
|
||||
t.Run("MemberAll", func(t *testing.T) {
|
||||
@@ -200,11 +200,11 @@ func TestScheduleShow(t *testing.T) {
|
||||
|
||||
// Then: they should only see their own
|
||||
// 1st workspace: c-member-ws3 has only autostop enabled.
|
||||
pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name)
|
||||
pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name)
|
||||
pty.ExpectMatch("8h")
|
||||
pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339))
|
||||
// 2nd workspace: d-member-ws4 has neither autostart nor autostop enabled.
|
||||
pty.ExpectMatch(ws[3].OwnerUsername + "/" + ws[3].Name)
|
||||
pty.ExpectMatch(ws[3].OwnerName + "/" + ws[3].Name)
|
||||
})
|
||||
|
||||
t.Run("JSON", func(t *testing.T) {
|
||||
@@ -231,25 +231,25 @@ func TestScheduleShow(t *testing.T) {
|
||||
return a < b
|
||||
})
|
||||
// 1st workspace: a-owner-ws1 has both autostart and autostop enabled.
|
||||
assert.Equal(t, ws[0].OwnerUsername+"/"+ws[0].Name, parsed[0]["workspace"])
|
||||
assert.Equal(t, ws[0].OwnerName+"/"+ws[0].Name, parsed[0]["workspace"])
|
||||
assert.Equal(t, sched.Humanize(), parsed[0]["starts_at"])
|
||||
assert.Equal(t, sched.Next(now).In(loc).Format(time.RFC3339), parsed[0]["starts_next"])
|
||||
assert.Equal(t, "8h", parsed[0]["stops_after"])
|
||||
assert.Equal(t, ws[0].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339), parsed[0]["stops_next"])
|
||||
// 2nd workspace: b-owner-ws2 has only autostart enabled.
|
||||
assert.Equal(t, ws[1].OwnerUsername+"/"+ws[1].Name, parsed[1]["workspace"])
|
||||
assert.Equal(t, ws[1].OwnerName+"/"+ws[1].Name, parsed[1]["workspace"])
|
||||
assert.Equal(t, sched.Humanize(), parsed[1]["starts_at"])
|
||||
assert.Equal(t, sched.Next(now).In(loc).Format(time.RFC3339), parsed[1]["starts_next"])
|
||||
assert.Empty(t, parsed[1]["stops_after"])
|
||||
assert.Empty(t, parsed[1]["stops_next"])
|
||||
// 3rd workspace: c-member-ws3 has only autostop enabled.
|
||||
assert.Equal(t, ws[2].OwnerUsername+"/"+ws[2].Name, parsed[2]["workspace"])
|
||||
assert.Equal(t, ws[2].OwnerName+"/"+ws[2].Name, parsed[2]["workspace"])
|
||||
assert.Empty(t, parsed[2]["starts_at"])
|
||||
assert.Empty(t, parsed[2]["starts_next"])
|
||||
assert.Equal(t, "8h", parsed[2]["stops_after"])
|
||||
assert.Equal(t, ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339), parsed[2]["stops_next"])
|
||||
// 4th workspace: d-member-ws4 has neither autostart nor autostop enabled.
|
||||
assert.Equal(t, ws[3].OwnerUsername+"/"+ws[3].Name, parsed[3]["workspace"])
|
||||
assert.Equal(t, ws[3].OwnerName+"/"+ws[3].Name, parsed[3]["workspace"])
|
||||
assert.Empty(t, parsed[3]["starts_at"])
|
||||
assert.Empty(t, parsed[3]["starts_next"])
|
||||
assert.Empty(t, parsed[3]["stops_after"])
|
||||
@@ -272,7 +272,7 @@ func TestScheduleModify(t *testing.T) {
|
||||
t.Run("SetStart", func(t *testing.T) {
|
||||
// When: we set the start schedule
|
||||
inv, root := clitest.New(t,
|
||||
"schedule", "start", ws[3].OwnerUsername+"/"+ws[3].Name, "7:30AM", "Mon-Fri", "Europe/Dublin",
|
||||
"schedule", "start", ws[3].OwnerName+"/"+ws[3].Name, "7:30AM", "Mon-Fri", "Europe/Dublin",
|
||||
)
|
||||
//nolint:gocritic // this workspace is not owned by the same user
|
||||
clitest.SetupConfig(t, ownerClient, root)
|
||||
@@ -280,7 +280,7 @@ func TestScheduleModify(t *testing.T) {
|
||||
require.NoError(t, inv.Run())
|
||||
|
||||
// Then: the updated schedule should be shown
|
||||
pty.ExpectMatch(ws[3].OwnerUsername + "/" + ws[3].Name)
|
||||
pty.ExpectMatch(ws[3].OwnerName + "/" + ws[3].Name)
|
||||
pty.ExpectMatch(sched.Humanize())
|
||||
pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339))
|
||||
})
|
||||
@@ -288,7 +288,7 @@ func TestScheduleModify(t *testing.T) {
|
||||
t.Run("SetStop", func(t *testing.T) {
|
||||
// When: we set the stop schedule
|
||||
inv, root := clitest.New(t,
|
||||
"schedule", "stop", ws[2].OwnerUsername+"/"+ws[2].Name, "8h30m",
|
||||
"schedule", "stop", ws[2].OwnerName+"/"+ws[2].Name, "8h30m",
|
||||
)
|
||||
//nolint:gocritic // this workspace is not owned by the same user
|
||||
clitest.SetupConfig(t, ownerClient, root)
|
||||
@@ -296,7 +296,7 @@ func TestScheduleModify(t *testing.T) {
|
||||
require.NoError(t, inv.Run())
|
||||
|
||||
// Then: the updated schedule should be shown
|
||||
pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name)
|
||||
pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name)
|
||||
pty.ExpectMatch("8h30m")
|
||||
pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339))
|
||||
})
|
||||
@@ -304,7 +304,7 @@ func TestScheduleModify(t *testing.T) {
|
||||
t.Run("UnsetStart", func(t *testing.T) {
|
||||
// When: we unset the start schedule
|
||||
inv, root := clitest.New(t,
|
||||
"schedule", "start", ws[1].OwnerUsername+"/"+ws[1].Name, "manual",
|
||||
"schedule", "start", ws[1].OwnerName+"/"+ws[1].Name, "manual",
|
||||
)
|
||||
//nolint:gocritic // this workspace is owned by owner
|
||||
clitest.SetupConfig(t, ownerClient, root)
|
||||
@@ -312,13 +312,13 @@ func TestScheduleModify(t *testing.T) {
|
||||
require.NoError(t, inv.Run())
|
||||
|
||||
// Then: the updated schedule should be shown
|
||||
pty.ExpectMatch(ws[1].OwnerUsername + "/" + ws[1].Name)
|
||||
pty.ExpectMatch(ws[1].OwnerName + "/" + ws[1].Name)
|
||||
})
|
||||
|
||||
t.Run("UnsetStop", func(t *testing.T) {
|
||||
// When: we unset the stop schedule
|
||||
inv, root := clitest.New(t,
|
||||
"schedule", "stop", ws[0].OwnerUsername+"/"+ws[0].Name, "manual",
|
||||
"schedule", "stop", ws[0].OwnerName+"/"+ws[0].Name, "manual",
|
||||
)
|
||||
//nolint:gocritic // this workspace is owned by owner
|
||||
clitest.SetupConfig(t, ownerClient, root)
|
||||
@@ -326,7 +326,7 @@ func TestScheduleModify(t *testing.T) {
|
||||
require.NoError(t, inv.Run())
|
||||
|
||||
// Then: the updated schedule should be shown
|
||||
pty.ExpectMatch(ws[0].OwnerUsername + "/" + ws[0].Name)
|
||||
pty.ExpectMatch(ws[0].OwnerName + "/" + ws[0].Name)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ func TestScheduleOverride(t *testing.T) {
|
||||
|
||||
// When: we override the stop schedule
|
||||
inv, root := clitest.New(t,
|
||||
"schedule", tt.command, ws[0].OwnerUsername+"/"+ws[0].Name, "10h",
|
||||
"schedule", tt.command, ws[0].OwnerName+"/"+ws[0].Name, "10h",
|
||||
)
|
||||
|
||||
clitest.SetupConfig(t, ownerClient, root)
|
||||
@@ -367,7 +367,7 @@ func TestScheduleOverride(t *testing.T) {
|
||||
require.NoError(t, inv.Run())
|
||||
|
||||
// Then: the updated schedule should be shown
|
||||
pty.ExpectMatch(ws[0].OwnerUsername + "/" + ws[0].Name)
|
||||
pty.ExpectMatch(ws[0].OwnerName + "/" + ws[0].Name)
|
||||
pty.ExpectMatch(sched.Humanize())
|
||||
pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339))
|
||||
pty.ExpectMatch("8h")
|
||||
|
||||
+2
-2
@@ -305,7 +305,7 @@ func (r *RootCmd) ssh() *serpent.Command {
|
||||
return xerrors.Errorf("get agent connection info: %w", err)
|
||||
}
|
||||
coderConnectHost := fmt.Sprintf("%s.%s.%s.%s",
|
||||
workspaceAgent.Name, workspace.Name, workspace.OwnerUsername, connInfo.HostnameSuffix)
|
||||
workspaceAgent.Name, workspace.Name, workspace.OwnerName, connInfo.HostnameSuffix)
|
||||
exists, _ := workspacesdk.ExistsViaCoderConnect(ctx, coderConnectHost)
|
||||
if exists {
|
||||
defer cancel()
|
||||
@@ -1022,7 +1022,7 @@ func verifyWorkspaceOutdated(client *codersdk.Client, workspace codersdk.Workspa
|
||||
|
||||
// Build the user workspace link which navigates to the Coder web UI.
|
||||
func buildWorkspaceLink(serverURL *url.URL, workspace codersdk.Workspace) *url.URL {
|
||||
return serverURL.ResolveReference(&url.URL{Path: fmt.Sprintf("@%s/%s", workspace.OwnerUsername, workspace.Name)})
|
||||
return serverURL.ResolveReference(&url.URL{Path: fmt.Sprintf("@%s/%s", workspace.OwnerName, workspace.Name)})
|
||||
}
|
||||
|
||||
// runLocal runs a command on the local machine.
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
fakeOwnerUsername = "fake-owner-name"
|
||||
fakeOwnerName = "fake-owner-name"
|
||||
fakeServerURL = "https://fake-foo-url"
|
||||
fakeWorkspaceName = "fake-workspace-name"
|
||||
)
|
||||
@@ -41,7 +41,7 @@ func TestVerifyWorkspaceOutdated(t *testing.T) {
|
||||
t.Run("Up-to-date", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerUsername: fakeOwnerUsername}
|
||||
workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerName: fakeOwnerName}
|
||||
|
||||
_, outdated := verifyWorkspaceOutdated(&client, workspace)
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestVerifyWorkspaceOutdated(t *testing.T) {
|
||||
t.Run("Outdated", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerUsername: fakeOwnerUsername, Outdated: true}
|
||||
workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerName: fakeOwnerName, Outdated: true}
|
||||
|
||||
updateWorkspaceBanner, outdated := verifyWorkspaceOutdated(&client, workspace)
|
||||
|
||||
@@ -65,10 +65,10 @@ func TestBuildWorkspaceLink(t *testing.T) {
|
||||
serverURL, err := url.Parse(fakeServerURL)
|
||||
require.NoError(t, err)
|
||||
|
||||
workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerUsername: fakeOwnerUsername}
|
||||
workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerName: fakeOwnerName}
|
||||
workspaceLink := buildWorkspaceLink(serverURL, workspace)
|
||||
|
||||
assert.Equal(t, workspaceLink.String(), fakeServerURL+"/@"+fakeOwnerUsername+"/"+fakeWorkspaceName)
|
||||
assert.Equal(t, workspaceLink.String(), fakeServerURL+"/@"+fakeOwnerName+"/"+fakeWorkspaceName)
|
||||
}
|
||||
|
||||
func TestCloserStack_Mainline(t *testing.T) {
|
||||
|
||||
+4
-4
@@ -148,7 +148,7 @@ func TestStart(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
require.NoError(t, err)
|
||||
actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID)
|
||||
require.NoError(t, err)
|
||||
@@ -191,7 +191,7 @@ func TestStart(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
require.NoError(t, err)
|
||||
actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID)
|
||||
require.NoError(t, err)
|
||||
@@ -247,7 +247,7 @@ func TestStartWithParameters(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
require.NoError(t, err)
|
||||
actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID)
|
||||
require.NoError(t, err)
|
||||
@@ -302,7 +302,7 @@ func TestStartWithParameters(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
|
||||
require.NoError(t, err)
|
||||
actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
"created_at": "====[timestamp]=====",
|
||||
"updated_at": "====[timestamp]=====",
|
||||
"owner_id": "==========[first user ID]===========",
|
||||
"owner_username": "testuser",
|
||||
"owner_name": "testuser",
|
||||
"owner_avatar_url": "",
|
||||
"organization_id": "===========[first org ID]===========",
|
||||
"organization_name": "coder",
|
||||
|
||||
Reference in New Issue
Block a user