Skip to content

Commit dc5189c

Browse files
committed
more test fixes
1 parent 784ee74 commit dc5189c

15 files changed

+102
-101
lines changed

coderd/coderd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func TestCSRFExempt(t *testing.T) {
355355
// Create a workspace.
356356
const agentSlug = "james"
357357
const appSlug = "web"
358-
wrk := dbfake.WorkspaceBuild(t, api.Database, database.Workspace{
358+
wrk := dbfake.WorkspaceBuild(t, api.Database, database.WorkspaceTable{
359359
OwnerID: owner.ID,
360360
OrganizationID: first.OrganizationID,
361361
}).

coderd/database/dbfake/dbfake.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var ownerCtx = dbauthz.As(context.Background(), rbac.Subject{
3232
})
3333

3434
type WorkspaceResponse struct {
35-
Workspace database.Workspace
35+
Workspace database.WorkspaceTable
3636
Build database.WorkspaceBuild
3737
AgentToken string
3838
TemplateVersionResponse
@@ -44,7 +44,7 @@ type WorkspaceBuildBuilder struct {
4444
t testing.TB
4545
db database.Store
4646
ps pubsub.Pubsub
47-
ws database.Workspace
47+
ws database.WorkspaceTable
4848
seed database.WorkspaceBuild
4949
resources []*sdkproto.Resource
5050
params []database.WorkspaceBuildParameter
@@ -60,7 +60,7 @@ type workspaceBuildDisposition struct {
6060
// Pass a database.Workspace{} with a nil ID to also generate a new workspace.
6161
// Omitting the template ID on a workspace will also generate a new template
6262
// with a template version.
63-
func WorkspaceBuild(t testing.TB, db database.Store, ws database.Workspace) WorkspaceBuildBuilder {
63+
func WorkspaceBuild(t testing.TB, db database.Store, ws database.WorkspaceTable) WorkspaceBuildBuilder {
6464
return WorkspaceBuildBuilder{t: t, db: db, ws: ws}
6565
}
6666

coderd/database/dbmem/dbmem.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ func (q *FakeQuerier) extendWorkspace(w database.WorkspaceTable) database.Worksp
549549
org, _ := slice.Find(q.organizations, func(o database.Organization) bool {
550550
return o.ID == w.OrganizationID
551551
})
552+
extended.OrganizationName = org.Name
552553
extended.OrganizationDescription = org.Description
553554
extended.OrganizationDisplayName = org.DisplayName
554555
extended.OrganizationIcon = org.Icon

coderd/database/dump.sql

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/migrations/000266_workspace_with_names.up.sql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ AS
44
SELECT
55
workspaces.*,
66
-- Owner
7-
coalesce(visible_users.avatar_url, '') AS owner_avatar_url,
8-
coalesce(visible_users.username, '') AS owner_username,
7+
visible_users.avatar_url AS owner_avatar_url,
8+
visible_users.username AS owner_username,
99
-- Organization
10-
coalesce(organizations.name, '') AS organization_name,
11-
coalesce(organizations.display_name, '') AS organization_display_name,
12-
coalesce(organizations.icon, '') AS organization_icon,
13-
coalesce(organizations.description, '') AS organization_description,
10+
organizations.name AS organization_name,
11+
organizations.display_name AS organization_display_name,
12+
organizations.icon AS organization_icon,
13+
organizations.description AS organization_description,
1414
-- Template
15-
coalesce(templates.name, '') AS template_name,
16-
coalesce(templates.display_name, '') AS template_display_name,
17-
coalesce(templates.icon, '') AS template_icon,
18-
coalesce(templates.description, '') AS template_description
15+
templates.name AS template_name,
16+
templates.display_name AS template_display_name,
17+
templates.icon AS template_icon,
18+
templates.description AS template_description
1919
FROM
2020
workspaces
21-
LEFT JOIN
21+
INNER JOIN
2222
visible_users
2323
ON
2424
workspaces.owner_id = visible_users.id
25-
LEFT JOIN
25+
INNER JOIN
2626
organizations
2727
ON workspaces.organization_id = organizations.id
28-
LEFT JOIN
28+
INNER JOIN
2929
templates
3030
ON workspaces.template_id = templates.id
3131
;

coderd/metricscache/metricscache_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestCache_TemplateWorkspaceOwners(t *testing.T) {
4949
"TemplateWorkspaceOwners never populated 0 owners",
5050
)
5151

52-
dbgen.Workspace(t, db, database.Workspace{
52+
dbgen.Workspace(t, db, database.WorkspaceTable{
5353
TemplateID: template.ID,
5454
OwnerID: user1.ID,
5555
})
@@ -61,7 +61,7 @@ func TestCache_TemplateWorkspaceOwners(t *testing.T) {
6161
"TemplateWorkspaceOwners never populated 1 owner",
6262
)
6363

64-
workspace2 := dbgen.Workspace(t, db, database.Workspace{
64+
workspace2 := dbgen.Workspace(t, db, database.WorkspaceTable{
6565
TemplateID: template.ID,
6666
OwnerID: user2.ID,
6767
})
@@ -74,7 +74,7 @@ func TestCache_TemplateWorkspaceOwners(t *testing.T) {
7474
)
7575

7676
// 3rd workspace should not be counted since we have the same owner as workspace2.
77-
dbgen.Workspace(t, db, database.Workspace{
77+
dbgen.Workspace(t, db, database.WorkspaceTable{
7878
TemplateID: template.ID,
7979
OwnerID: user1.ID,
8080
})

coderd/users_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ func TestUserAutofillParameters(t *testing.T) {
19361936
},
19371937
).Do()
19381938

1939-
dbfake.WorkspaceBuild(t, db, database.Workspace{
1939+
dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
19401940
OwnerID: u2.ID,
19411941
TemplateID: version.Template.ID,
19421942
OrganizationID: u1.OrganizationID,
@@ -1969,7 +1969,7 @@ func TestUserAutofillParameters(t *testing.T) {
19691969
require.Equal(t, "foo", params[0].Value)
19701970

19711971
// Verify that latest parameter value is returned.
1972-
dbfake.WorkspaceBuild(t, db, database.Workspace{
1972+
dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
19731973
OrganizationID: u1.OrganizationID,
19741974
OwnerID: u2.ID,
19751975
TemplateID: version.Template.ID,

coderd/workspaceagentportshare_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestPostWorkspaceAgentPortShare(t *testing.T) {
2424
client, user := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID)
2525

2626
tmpDir := t.TempDir()
27-
r := dbfake.WorkspaceBuild(t, db, database.Workspace{
27+
r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
2828
OrganizationID: owner.OrganizationID,
2929
OwnerID: user.ID,
3030
}).WithAgent(func(agents []*proto.Agent) []*proto.Agent {
@@ -141,7 +141,7 @@ func TestGetWorkspaceAgentPortShares(t *testing.T) {
141141
client, user := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID)
142142

143143
tmpDir := t.TempDir()
144-
r := dbfake.WorkspaceBuild(t, db, database.Workspace{
144+
r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
145145
OrganizationID: owner.OrganizationID,
146146
OwnerID: user.ID,
147147
}).WithAgent(func(agents []*proto.Agent) []*proto.Agent {
@@ -177,7 +177,7 @@ func TestDeleteWorkspaceAgentPortShare(t *testing.T) {
177177
client, user := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID)
178178

179179
tmpDir := t.TempDir()
180-
r := dbfake.WorkspaceBuild(t, db, database.Workspace{
180+
r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
181181
OrganizationID: owner.OrganizationID,
182182
OwnerID: user.ID,
183183
}).WithAgent(func(agents []*proto.Agent) []*proto.Agent {

0 commit comments

Comments
 (0)