diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-11-17 18:26:07 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-11-19 16:24:27 +0300 |
commit | 84aa3b927dd792d806fd80e0c5730f52f087ce89 (patch) | |
tree | 0d817d5807b4ee0700f961e7d9a05275390646d7 | |
parent | d0d2e010ee004c93b3acd269c97fe8501f54c1c2 (diff) |
repository: Fix archive LFS test writing into repo
The testcase `TestGetArchiveWithLfsSuccess()` is setting up a GitLab
server together with gitlab-shell. But as `SetupAndStartGitlabServer`
depends on the global Gitaly config in order to determine where the
gitlab-shell directory is, and that config value isn't yet set up when
the function is called, the secret ends up in a path relative to the
current working directory.
Fix the issue by modifying the global configuration before calling
`SetupAndStartGitlabServer()`.
-rw-r--r-- | internal/gitaly/service/repository/archive_test.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/internal/gitaly/service/repository/archive_test.go b/internal/gitaly/service/repository/archive_test.go index dfba15ee9..79a8a5942 100644 --- a/internal/gitaly/service/repository/archive_test.go +++ b/internal/gitaly/service/repository/archive_test.go @@ -180,13 +180,22 @@ func TestGetArchiveWithLfsSuccess(t *testing.T) { LfsBody: lfsBody, } + gitlabShellDir, cleanup := testhelper.TempDir(t) + defer cleanup() + + defer func(cfg config.Cfg) { + config.Config = cfg + }(config.Config) + + config.Config.GitlabShell.Dir = gitlabShellDir + config.Config.Gitlab.SecretFile = filepath.Join(config.Config.GitlabShell.Dir, ".gitlab_shell_secret") + url, cleanup := testhelper.SetupAndStartGitlabServer(t, &defaultOptions) defer cleanup() - cfg := config.Config - cfg.Gitlab.URL = url - cfg.Gitlab.SecretFile = filepath.Join(cfg.GitlabShell.Dir, ".gitlab_shell_secret") - serverSocketPath, stop := runRepoServerWithConfig(t, cfg, config.NewLocator(cfg)) + config.Config.Gitlab.URL = url + + serverSocketPath, stop := runRepoServerWithConfig(t, config.Config, config.NewLocator(config.Config)) defer stop() client, conn := newRepositoryClient(t, serverSocketPath) |