From aa756880510affd04ea4a4e146da6818d08cdb74 Mon Sep 17 00:00:00 2001 From: Ben Brooks Date: Thu, 7 Aug 2025 13:26:21 +0100 Subject: [PATCH] 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) --- base/logging_context.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/base/logging_context.go b/base/logging_context.go index 3231b299f5..03da897e3e 100644 --- a/base/logging_context.go +++ b/base/logging_context.go @@ -176,9 +176,7 @@ func NewTaskID(contextID string, taskName string) string { // TestCtx creates a context for the given test which is also cancelled once the test has completed. func TestCtx(t testing.TB) context.Context { - ctx, cancelCtx := context.WithCancel(context.Background()) - t.Cleanup(cancelCtx) - return LogContextWith(ctx, &LogContext{TestName: t.Name()}) + return LogContextWith(t.Context(), &LogContext{TestName: t.Name()}) } // BucketCtx extends the parent context with a bucket name.