mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
fix(coderd): fix memory leak in watchWorkspaceAgentMetadata
(#10685)
Fixes #10550
This commit is contained in:
committed by
GitHub
parent
c130f8d6d0
commit
198b56c137
23
testutil/go.go
Normal file
23
testutil/go.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user