diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-07-06 10:48:33 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-07-07 07:50:27 +0300 |
commit | 6d3c36e60a3923c4c7d755caa4f454c19eb3de24 (patch) | |
tree | 5b8700c351c23aaa646dc6301fd2d68becdf2046 | |
parent | bf214c40cdea0f390e885298d7cf74056c68c6f2 (diff) |
testhelper: Remove `testhelper.ModifyEnvironment()` helperpks-testhelper-unsetenv
Remove the `testhelper.ModifyEnvironment()` helper. One should instead
either use `t.Setenv()` or `testhelper.Unsetenv()`.
-rw-r--r-- | internal/testhelper/testhelper.go | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go index c5af5b254..e917a7b79 100644 --- a/internal/testhelper/testhelper.go +++ b/internal/testhelper/testhelper.go @@ -267,23 +267,6 @@ func WriteExecutable(t testing.TB, path string, content []byte) string { return path } -// ModifyEnvironment will change an environment variable and revert it when the test completed. -func ModifyEnvironment(t testing.TB, key string, value string) { - t.Helper() - - oldValue, hasOldValue := os.LookupEnv(key) - if value == "" { - require.NoError(t, os.Unsetenv(key)) - t.Cleanup(func() { - if hasOldValue { - require.NoError(t, os.Setenv(key, oldValue)) - } - }) - } else { - t.Setenv(key, value) - } -} - // Unsetenv unsets an environment variable. The variable will be restored after the test has // finished. func Unsetenv(t testing.TB, key string) { |