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

Simplify config tests by using T.Setenv, T.TempDir #2014

Merged
merged 1 commit into from
May 15, 2024

Conversation

alexandear
Copy link
Contributor

The PR simplifies config tests by refactoring code and without harming readability:

  • Use T.Setenv instead of os.Setenv. Because T.Setenv calls os.Setenv(key, value) and uses T.Cleanup to restore the environment variable to its original value after the test. So, the test doesn't need to restore the environment by itself.
  • Use T.TempDir instead of os.CreateTemp to create a temporary file. TempDir returns a temporary directory which is automatically removed when the test and all its subtests complete.

@jackc jackc merged commit 0080acf into jackc:master May 15, 2024
14 checks passed
@jackc
Copy link
Owner

jackc commented May 15, 2024

Thanks!

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