@@ -44,9 +44,9 @@ func TestBlockNonBrowser(t *testing.T) {
44
44
},
45
45
},
46
46
})
47
- _ , agent := setupWorkspaceAgent (t , client , user , 0 )
47
+ r := setupWorkspaceAgent (t , client , user , 0 )
48
48
//nolint:gocritic // Testing that even the owner gets blocked.
49
- _ , err := client .DialWorkspaceAgent (context .Background (), agent .ID , nil )
49
+ _ , err := client .DialWorkspaceAgent (context .Background (), r . sdkAgent .ID , nil )
50
50
var apiErr * codersdk.Error
51
51
require .ErrorAs (t , err , & apiErr )
52
52
require .Equal (t , http .StatusConflict , apiErr .StatusCode ())
@@ -63,15 +63,21 @@ func TestBlockNonBrowser(t *testing.T) {
63
63
},
64
64
},
65
65
})
66
- _ , agent := setupWorkspaceAgent (t , client , user , 0 )
66
+ r := setupWorkspaceAgent (t , client , user , 0 )
67
67
//nolint:gocritic // Testing RBAC is not the point of this test.
68
- conn , err := client .DialWorkspaceAgent (context .Background (), agent .ID , nil )
68
+ conn , err := client .DialWorkspaceAgent (context .Background (), r . sdkAgent .ID , nil )
69
69
require .NoError (t , err )
70
70
_ = conn .Close ()
71
71
})
72
72
}
73
73
74
- func setupWorkspaceAgent (t * testing.T , client * codersdk.Client , user codersdk.CreateFirstUserResponse , appPort uint16 ) (codersdk.Workspace , codersdk.WorkspaceAgent ) {
74
+ type setupResp struct {
75
+ workspace codersdk.Workspace
76
+ sdkAgent codersdk.WorkspaceAgent
77
+ agent agent.Agent
78
+ }
79
+
80
+ func setupWorkspaceAgent (t * testing.T , client * codersdk.Client , user codersdk.CreateFirstUserResponse , appPort uint16 ) setupResp {
75
81
authToken := uuid .NewString ()
76
82
version := coderdtest .CreateTemplateVersion (t , client , user .OrganizationID , & echo.Responses {
77
83
Parse : echo .ParseComplete ,
@@ -127,20 +133,20 @@ func setupWorkspaceAgent(t *testing.T, client *codersdk.Client, user codersdk.Cr
127
133
},
128
134
}
129
135
agentClient .SetSessionToken (authToken )
130
- agentCloser := agent .New (agent.Options {
136
+ agnt := agent .New (agent.Options {
131
137
Client : agentClient ,
132
138
Logger : slogtest .Make (t , nil ).Named ("agent" ),
133
139
})
134
140
t .Cleanup (func () {
135
- _ = agentCloser .Close ()
141
+ _ = agnt .Close ()
136
142
})
137
143
138
144
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
139
145
defer cancel ()
140
146
141
147
resources := coderdtest .AwaitWorkspaceAgents (t , client , workspace .ID )
142
- agnt , err := client .WorkspaceAgent (ctx , resources [0 ].Agents [0 ].ID )
148
+ sdkAgent , err := client .WorkspaceAgent (ctx , resources [0 ].Agents [0 ].ID )
143
149
require .NoError (t , err )
144
150
145
- return workspace , agnt
151
+ return setupResp { workspace , sdkAgent , agnt }
146
152
}
0 commit comments