Skip to content

test: use t.Context() instead of context.Background()#3525

Merged
knative-prow[bot] merged 1 commit intoknative:mainfrom
matejvasek:test-context
Mar 25, 2026
Merged

test: use t.Context() instead of context.Background()#3525
knative-prow[bot] merged 1 commit intoknative:mainfrom
matejvasek:test-context

Conversation

@matejvasek
Copy link
Copy Markdown
Contributor

No description provided.

Replace context.Background() and context.TODO() with the
testing context t.Context() (available since Go 1.24) across
all test files. This ties context lifecycle to the test
lifecycle, providing automatic cancellation when tests end.

Cleanup functions (t.Cleanup) retain context.Background()
since t.Context() is cancelled before cleanup runs.

Unused "context" imports are removed where applicable.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@knative-prow knative-prow Bot added the approved 🤖 PR has been approved by an approver from all required OWNERS files. label Mar 25, 2026
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos March 25, 2026 14:05
@knative-prow knative-prow Bot added the size/L 🤖 PR changes 100-499 lines, ignoring generated files. label Mar 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.54%. Comparing base (3155f3c) to head (3e098cb).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3525      +/-   ##
==========================================
- Coverage   55.55%   55.54%   -0.01%     
==========================================
  Files         180      180              
  Lines       20465    20465              
==========================================
- Hits        11370    11368       -2     
- Misses       7896     7898       +2     
  Partials     1199     1199              
Flag Coverage Δ
e2e 40.21% <ø> (ø)
e2e go 32.55% <ø> (ø)
e2e node 28.36% <ø> (ø)
e2e python 32.91% <ø> (ø)
e2e quarkus 28.50% <ø> (ø)
e2e rust 27.92% <ø> (+0.01%) ⬆️
e2e springboot 26.38% <ø> (+0.02%) ⬆️
e2e typescript 28.47% <ø> (ø)
e2e-config-ci 18.14% <ø> (ø)
integration 17.43% <ø> (ø)
unit macos-14 43.37% <ø> (ø)
unit macos-latest 43.37% <ø> (ø)
unit ubuntu-24.04-arm 43.57% <ø> (ø)
unit ubuntu-latest 44.25% <ø> (ø)
unit windows-latest 43.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gauron99
Copy link
Copy Markdown
Contributor

/lgtm
/approve

@gauron99 gauron99 closed this Mar 25, 2026
@gauron99 gauron99 reopened this Mar 25, 2026
@gauron99
Copy link
Copy Markdown
Contributor

ehm what?

@gauron99
Copy link
Copy Markdown
Contributor

/lgtm
/approve

@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label Mar 25, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented Mar 25, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99, matejvasek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [gauron99,matejvasek]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot merged commit 2807721 into knative:main Mar 25, 2026
80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. lgtm 🤖 PR is ready to be merged. size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants