@@ -115,7 +115,7 @@ func newWithCloser(t *testing.T, options *Options) (*codersdk.Client, io.Closer)
115
115
return client , closer
116
116
}
117
117
118
- func NewOptions (t * testing.T , options * Options ) (* httptest.Server , * coderd.Options ) {
118
+ func NewOptions (t * testing.T , options * Options ) (* httptest.Server , context. CancelFunc , * coderd.Options ) {
119
119
if options == nil {
120
120
options = & Options {}
121
121
}
@@ -194,7 +194,7 @@ func NewOptions(t *testing.T, options *Options) (*httptest.Server, *coderd.Optio
194
194
options .SSHKeygenAlgorithm = gitsshkey .AlgorithmEd25519
195
195
}
196
196
197
- return srv , & coderd.Options {
197
+ return srv , cancelFunc , & coderd.Options {
198
198
AgentConnectionUpdateFrequency : 150 * time .Millisecond ,
199
199
// Force a long disconnection timeout to ensure
200
200
// agents are not marked as disconnected during slow tests.
@@ -246,10 +246,11 @@ func NewWithAPI(t *testing.T, options *Options) (*codersdk.Client, io.Closer, *c
246
246
if options == nil {
247
247
options = & Options {}
248
248
}
249
- srv , newOptions := NewOptions (t , options )
249
+ srv , cancelFunc , newOptions := NewOptions (t , options )
250
250
// We set the handler after server creation for the access URL.
251
251
coderAPI := coderd .New (newOptions )
252
252
t .Cleanup (func () {
253
+ cancelFunc ()
253
254
_ = coderAPI .Close ()
254
255
})
255
256
srv .Config .Handler = coderAPI .RootHandler
0 commit comments