2022-10-10 15:37:06 -05:00
|
|
|
package testutil
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"testing"
|
2023-03-23 17:42:20 -05:00
|
|
|
"time"
|
2022-10-10 15:37:06 -05:00
|
|
|
)
|
|
|
|
|
|
2025-08-18 23:51:19 +10:00
|
|
|
func Context(t testing.TB, dur time.Duration) context.Context {
|
2023-03-23 17:42:20 -05:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), dur)
|
2022-10-10 15:37:06 -05:00
|
|
|
t.Cleanup(cancel)
|
2023-03-23 17:42:20 -05:00
|
|
|
return ctx
|
2022-10-10 15:37:06 -05:00
|
|
|
}
|