@@ -1515,14 +1515,17 @@ func TestWorkspaceAgentAppHealth(t *testing.T) {
1515
1515
}).Do ()
1516
1516
1517
1517
res := dbgen .WorkspaceResource (t ,db , database.WorkspaceResource {JobID :r .Build .JobID })
1518
- agent := dbgen .WorkspaceAgent (t ,db , database.WorkspaceAgent {ResourceID :res .ID })
1518
+ agnt := dbgen .WorkspaceAgent (t ,db , database.WorkspaceAgent {ResourceID :res .ID })
1519
+
1520
+ //nolint:gocritic // It's a test it's ok.
1521
+ asSystemCtx := dbauthz .AsSystemRestricted (t .Context ())
1519
1522
1520
1523
// It's simpler to call db.InsertWorkspaceApp directly than dbgen.WorkspaceApp because it's more terse and direct;
1521
1524
// the latter sets a bunch of defaults which make this test hard.
1522
- _ ,err := db .InsertWorkspaceApp (dbauthz . AsSystemRestricted ( t . Context ()) , database.InsertWorkspaceAppParams {
1525
+ _ ,err := db .InsertWorkspaceApp (asSystemCtx , database.InsertWorkspaceAppParams {
1523
1526
ID :uuid .New (),
1524
1527
Slug :"code-server" ,
1525
- AgentID :agent .ID ,
1528
+ AgentID :agnt .ID ,
1526
1529
Icon :"/code.svg" ,
1527
1530
Command : sql.NullString {String :"some-command" ,Valid :true },
1528
1531
Url : sql.NullString {String :"http://localhost:3000" ,Valid :true },
@@ -1531,11 +1534,11 @@ func TestWorkspaceAgentAppHealth(t *testing.T) {
1531
1534
OpenIn :database .WorkspaceAppOpenInWindow ,
1532
1535
})
1533
1536
require .NoError (t ,err )
1534
- _ ,err = db .InsertWorkspaceApp (dbauthz . AsSystemRestricted ( t . Context ()) , database.InsertWorkspaceAppParams {
1537
+ _ ,err = db .InsertWorkspaceApp (asSystemCtx , database.InsertWorkspaceAppParams {
1535
1538
ID :uuid .New (),
1536
1539
Slug :"code-server-2" ,
1537
1540
DisplayName :"code-server-2" ,
1538
- AgentID :agent .ID ,
1541
+ AgentID :agnt .ID ,
1539
1542
Icon :"/code.svg" ,
1540
1543
Command : sql.NullString {String :"some-command" ,Valid :true },
1541
1544
Url : sql.NullString {String :"http://localhost:3000" ,Valid :true },
@@ -1552,7 +1555,7 @@ func TestWorkspaceAgentAppHealth(t *testing.T) {
1552
1555
defer cancel ()
1553
1556
1554
1557
agentClient := agentsdk .New (client .URL )
1555
- agentClient .SetSessionToken (agent .AuthToken .String ())
1558
+ agentClient .SetSessionToken (agnt .AuthToken .String ())
1556
1559
conn ,err := agentClient .ConnectRPC (ctx )
1557
1560
require .NoError (t ,err )
1558
1561
defer func () {