Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cmd): safer and simpler cmd test env #2565

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Exca-DK
Copy link
Contributor

@Exca-DK Exca-DK commented Feb 25, 2025

This change replaces manual environment variable handling with t.Setenv, which simplifies the logic and ensures proper cleanup.

t.Setenv automatically restores the previous value (or removes it if it didn’t exist) using t.Cleanup, making the tests more robust, even in case of a crash.

Also makes my linter happy since its been screaming for some time for usage of os.setenv in tests.

Ref: t.Setenv

@weiihann weiihann changed the title Safer and simpler cmd test env test(cmd): safer and simpler cmd test env Mar 10, 2025
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.22%. Comparing base (19cf1c4) to head (f43213b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2565      +/-   ##
==========================================
+ Coverage   75.20%   75.22%   +0.02%     
==========================================
  Files         140      140              
  Lines       16862    16862              
==========================================
+ Hits        12681    12685       +4     
+ Misses       3353     3350       -3     
+ Partials      828      827       -1     

☔ 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.

@weiihann weiihann force-pushed the Exca-DK/safer-test-osenv branch from 91122aa to f43213b Compare March 10, 2025 08:39
Copy link
Contributor

@weiihann weiihann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants