diff options
-rw-r--r-- | internal/git/command_factory_test.go | 5 | ||||
-rw-r--r-- | internal/git/hooks/hooks_test.go | 9 |
2 files changed, 3 insertions, 11 deletions
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go index 6b3157791..c80ea1a84 100644 --- a/internal/git/command_factory_test.go +++ b/internal/git/command_factory_test.go @@ -5,7 +5,6 @@ import ( "io" "net/http" "net/http/httptest" - "os" "testing" "github.com/stretchr/testify/require" @@ -26,9 +25,7 @@ func TestGitCommandProxy(t *testing.T) { })) defer ts.Close() - oldHTTPProxy := os.Getenv("http_proxy") - defer require.NoError(t, os.Setenv("http_proxy", oldHTTPProxy)) - require.NoError(t, os.Setenv("http_proxy", ts.URL)) + testhelper.ModifyEnvironment(t, "http_proxy", ts.URL) ctx, cancel := testhelper.Context() defer cancel() diff --git a/internal/git/hooks/hooks_test.go b/internal/git/hooks/hooks_test.go index e094a9c5d..f8d17f5de 100644 --- a/internal/git/hooks/hooks_test.go +++ b/internal/git/hooks/hooks_test.go @@ -1,11 +1,11 @@ package hooks import ( - "os" "testing" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config" + "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper" ) func TestPath(t *testing.T) { @@ -23,12 +23,7 @@ func TestPath(t *testing.T) { }) t.Run("when an env override", func(t *testing.T) { - key := "GITALY_TESTING_NO_GIT_HOOKS" - - require.NoError(t, os.Setenv(key, "1")) - defer func() { - require.NoError(t, os.Unsetenv(key)) - }() + testhelper.ModifyEnvironment(t, "GITALY_TESTING_NO_GIT_HOOKS", "1") require.Equal(t, "/var/empty", Path(cfg)) }) |