Commit ff439ea
authored
refactor: use t.Setenv instead of os.Setenv in tests
This PR refactors the test suite to use the testing framework’s Setenv helper instead of direct os.Setenv calls. By leveraging Setenv on *testing.T or *testing.M, we ensure automatic cleanup of environment variables and streamline error handling.
- Use `t.Setenv` and friends instead of `os.Setenv` for test file(s): The original code manually invoked os.Setenv and exited on error, risking persistent side effects and boilerplate error handling. The patch replaces this with a call to m.Setenv (the *testing.M helper), which automatically restores the previous environment value after the test run and fails the test on setup errors, improving test isolation and readability.
> This Autofix was generated by AI. Please review the change before merging.1 parent da43d0b commit ff439ea
1 file changed
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
| 25 | + | |
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
| |||
0 commit comments