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>2022-08-02 15:44:50 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-03 07:58:02 +0300
commit76793b421849c09a549a96e8711c9ba3519dbe7c (patch)
treebf7893a6c10069b8c2af8afa9f45d00a6804fe3f
parentb799d0b98f26e3de2fc408bf2b83eb86fb330858 (diff)
repository: Amend test to only intercept some Git commands
One of our tests for the `GetArchive()` RPC uses an intercepting command factory to assert that git-archive(1) in fact sees expected environment variables. This is done by unconditionally intercepting any Git command spawned and replacing it with a call to env(1), which only works right now because we only ever spawn any other command in this code path at the moment. This is about to change though with the introduction of the object hash format detection. Refactor the test to only intercept calls to git-archive(1) in order for the test not to break when we start spawning other Git commands.
-rw-r--r--internal/gitaly/service/repository/archive_test.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/internal/gitaly/service/repository/archive_test.go b/internal/gitaly/service/repository/archive_test.go
index 5f18f8679..ce90c525e 100644
--- a/internal/gitaly/service/repository/archive_test.go
+++ b/internal/gitaly/service/repository/archive_test.go
@@ -466,10 +466,15 @@ func TestGetArchive_environment(t *testing.T) {
ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
- gitCmdFactory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(git.ExecutionEnvironment) string {
- return `#!/bin/sh
+ // Intercept commands to git-archive(1) to print the environment. Note that we continue to
+ // execute any other Git commands so that the command factory behaves as expected.
+ gitCmdFactory := gittest.NewInterceptingCommandFactory(ctx, t, cfg, func(execEnv git.ExecutionEnvironment) string {
+ return fmt.Sprintf(`#!/bin/bash
+ if [[ ! "$@" =~ "archive" ]]; then
+ exec %q "$@"
+ fi
env | grep -E '^GL_|CORRELATION|GITALY_'
- `
+ `, execEnv.BinaryPath)
})
testcfg.BuildGitalyHooks(t, cfg)