Skip to content

Commit aa75688

Browse files
committed
Use Go 1.24's testing.T.Context() instead of doing it ourselves (they function very similarly - just prior to test Cleanup() the test context is cancelled)
1 parent 45b3bbf commit aa75688

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

base/logging_context.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ func NewTaskID(contextID string, taskName string) string {
176176

177177
// TestCtx creates a context for the given test which is also cancelled once the test has completed.
178178
func TestCtx(t testing.TB) context.Context {
179-
ctx, cancelCtx := context.WithCancel(context.Background())
180-
t.Cleanup(cancelCtx)
181-
return LogContextWith(ctx, &LogContext{TestName: t.Name()})
179+
return LogContextWith(t.Context(), &LogContext{TestName: t.Name()})
182180
}
183181

184182
// BucketCtx extends the parent context with a bucket name.

0 commit comments

Comments
 (0)