diff options
author | Igor Wiedler <iwiedler@gitlab.com> | 2020-11-19 14:32:14 +0100 |
---|---|---|
committer | Igor Wiedler <iwiedler@gitlab.com> | 2020-11-19 14:32:14 +0100 |
commit | f558aa505cb2803cc0680e9176f1e78b1f1a711a (patch) | |
tree | c837c4ff457cc226571de72766b188700001b2c8 /internal/handler/exec_test.go | |
parent | cd3129c383d02aadbd8703a0483e85b444072205 (diff) | |
download | gitlab-shell-client-identity.tar.gz |
use testhelper for SSH_CONNECTIONclient-identity
Diffstat (limited to 'internal/handler/exec_test.go')
-rw-r--r-- | internal/handler/exec_test.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/handler/exec_test.go b/internal/handler/exec_test.go index 326bfee..89f2526 100644 --- a/internal/handler/exec_test.go +++ b/internal/handler/exec_test.go @@ -3,7 +3,6 @@ package handler import ( "context" "errors" - "os" "testing" "github.com/stretchr/testify/require" @@ -13,6 +12,7 @@ import ( pb "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/accessverifier" + "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper" ) func makeHandler(t *testing.T, err error) func(context.Context, *grpc.ClientConn) (int32, error) { @@ -124,11 +124,11 @@ func TestPrepareContext(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - ctx := context.Background() + cleanup, err := testhelper.Setenv("SSH_CONNECTION", tt.sshConnectionEnv) + require.NoError(t, err) + defer cleanup() - orig := os.Getenv("SSH_CONNECTION") - defer os.Setenv("SSH_CONNECTION", orig) - os.Setenv("SSH_CONNECTION", tt.sshConnectionEnv) + ctx := context.Background() ctx, cancel := tt.gc.PrepareContext(ctx, tt.repo, tt.response, "protocol") defer cancel() |