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:
authorPavlo Strokov <pstrokov@gitlab.com>2021-02-13 02:22:51 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2021-02-13 02:22:51 +0300
commit1724a2847f39effcf3317b501fda0c7310f9be7a (patch)
tree9df2fa11373de52f402d05ede73881bd2d96f8a0 /internal/testhelper/testserver.go
parentfeade4da693bb6657c16960d6bc988378527b9a0 (diff)
Gitaly-ruby server should not depend on the global state
Configuration of the gitaly-ruby server depends on the global config.Config variable. As we are on the road to removing it this change break this dependency by introducing a constructor function that accepts required configuration. That change requires refactoring of the gitaly-ruby test instance setup - now it should be created only after configuration is properly set. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
Diffstat (limited to 'internal/testhelper/testserver.go')
-rw-r--r--internal/testhelper/testserver.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go
index 119e387f4..57bd3e15c 100644
--- a/internal/testhelper/testserver.go
+++ b/internal/testhelper/testserver.go
@@ -825,6 +825,8 @@ type GitlabTestServerOptions struct {
// NewGitlabTestServer returns a mock gitlab server that responds to the hook api endpoints
func NewGitlabTestServer(t testing.TB, options GitlabTestServerOptions) (url string, cleanup func()) {
+ t.Helper()
+
mux := http.NewServeMux()
prefix := strings.TrimRight(options.RelativeURLRoot, "/") + "/api/v4/internal"
mux.Handle(prefix+"/allowed", http.HandlerFunc(handleAllowed(t, options)))
@@ -911,6 +913,8 @@ func WriteTemporaryGitalyConfigFile(t testing.TB, tempDir, gitlabURL, user, pass
// WriteShellSecretFile writes a .gitlab_shell_secret file in the specified directory
func WriteShellSecretFile(t testing.TB, dir, secretToken string) {
+ t.Helper()
+
require.NoError(t, os.MkdirAll(dir, os.ModeDir))
require.NoError(t, ioutil.WriteFile(filepath.Join(dir, ".gitlab_shell_secret"), []byte(secretToken), 0644))
}
@@ -945,10 +949,10 @@ func NewHealthServerWithListener(t testing.TB, listener net.Listener) (*grpc.Ser
// SetupAndStartGitlabServer creates a new GitlabTestServer, starts it and sets
// up the gitlab-shell secret.
-func SetupAndStartGitlabServer(t testing.TB, c *GitlabTestServerOptions) (string, func()) {
+func SetupAndStartGitlabServer(t testing.TB, shellDir string, c *GitlabTestServerOptions) (string, func()) {
url, cleanup := NewGitlabTestServer(t, *c)
- WriteShellSecretFile(t, config.Config.GitlabShell.Dir, c.SecretToken)
+ WriteShellSecretFile(t, shellDir, c.SecretToken)
return url, cleanup
}