fix(coderd): fix memory leak in watchWorkspaceAgentMetadata (#10685)

Fixes #10550
This commit is contained in:
Mathias Fredriksson
2023-11-16 17:03:53 +02:00
committed by GitHub
parent c130f8d6d0
commit 198b56c137
4 changed files with 269 additions and 43 deletions

23
testutil/go.go Normal file
View File

@ -0,0 +1,23 @@
package testutil
import (
"testing"
)
// Go runs fn in a goroutine and waits until fn has completed before
// test completion. Done is returned for optionally waiting for fn to
// exit.
func Go(t *testing.T, fn func()) (done <-chan struct{}) {
t.Helper()
doneC := make(chan struct{})
t.Cleanup(func() {
<-doneC
})
go func() {
fn()
close(doneC)
}()
return doneC
}