Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove unused testutil function
  • Loading branch information
mafredri committed Nov 16, 2023
commit 1da56e69616a41c789c4612c1def64454d229aa6
22 changes: 0 additions & 22 deletions testutil/go.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package testutil

import (
"context"
"testing"
)

Expand All @@ -22,24 +21,3 @@ func Go(t *testing.T, fn func()) (done <-chan struct{}) {

return doneC
}

// GoContext runs fn in a goroutine passing a context that will be
// canceled on test completion and wait until fn has finished executing.
// Done and cancel are returned for optionally waiting until completion
// or early cancellation.
func GoContext(t *testing.T, fn func(context.Context)) (done <-chan struct{}, cancel context.CancelFunc) {
t.Helper()

ctx, cancel := context.WithCancel(context.Background())
doneC := make(chan struct{})
t.Cleanup(func() {
cancel()
<-done
})
go func() {
fn(ctx)
close(doneC)
}()

return doneC, cancel
}