Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-10-27 17:24:44 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-10-27 17:31:39 +0300
commit7d65ce6a898f215615988a0dfba5d2312bcb4c23 (patch)
tree2043dc086a776afd0638b4ebe0bc1ef98b85cb98
parent826c0d7bab71a9ca70096f4abeec7541da36db37 (diff)
global: Convert to use `ModifyEnvironment()`pks-testing-parallel-environment
Tests shouldn't use `os.Setenv()` and `os.Unsetenv()`, but instead our own `testhelper.ModifyEnvironment()` function which guards us against modifying the environment in parallel tests. Convert tests which do use these functions to use our helper function.
-rw-r--r--internal/git/command_factory_test.go5
-rw-r--r--internal/git/hooks/hooks_test.go9
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))
})