diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2022-02-21 12:24:09 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2022-02-23 14:22:04 +0300 |
commit | 5534d65713f23389ab606eabccde3b0db37de8cf (patch) | |
tree | f7459931670c0b7da7dc9c699303bdc3cc5b089d | |
parent | f2e66ff7be7f19481a919a8794e451e7db72b3d3 (diff) |
Pull unconfigured socket path message into a constant
testcfg.Build doesn't yet know the socket path when building the
configuration. The socket path is substituted into the configuration
when the service being spun up. The message used to bypass config
validation error is spread in multiple locations in the code base.
This commit pulls it into a constant.
-rw-r--r-- | internal/git/localrepo/repo.go | 3 | ||||
-rw-r--r-- | internal/testhelper/testcfg/gitaly_builder.go | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/internal/git/localrepo/repo.go b/internal/git/localrepo/repo.go index 7c4eabce8..806b61553 100644 --- a/internal/git/localrepo/repo.go +++ b/internal/git/localrepo/repo.go @@ -14,6 +14,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/storage" "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper" + "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg" "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" ) @@ -40,7 +41,7 @@ func New(locator storage.Locator, gitCmdFactory git.CommandFactory, catfileCache func NewTestRepo(t testing.TB, cfg config.Cfg, repo repository.GitRepo, factoryOpts ...git.ExecCommandFactoryOption) *Repo { t.Helper() - if cfg.SocketPath != "it is a stub to bypass Validate method" { + if cfg.SocketPath != testcfg.UnconfiguredSocketPath { repo = gittest.RewrittenRepository(testhelper.Context(t), t, cfg, &gitalypb.Repository{ StorageName: repo.GetStorageName(), RelativePath: repo.GetRelativePath(), diff --git a/internal/testhelper/testcfg/gitaly_builder.go b/internal/testhelper/testcfg/gitaly_builder.go index fb4d1b466..3f670ebcb 100644 --- a/internal/testhelper/testcfg/gitaly_builder.go +++ b/internal/testhelper/testcfg/gitaly_builder.go @@ -13,6 +13,12 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" ) +// UnconfiguredSocketPath is used to bypass config validation errors +// when building the configuration. The socket path is now known yet +// at the time of building the configuration and is substituted later +// when the service is actually spun up. +const UnconfiguredSocketPath = "it is a stub to bypass Validate method" + // Option is a configuration option for the builder. type Option func(*GitalyCfgBuilder) @@ -74,7 +80,7 @@ func (gc *GitalyCfgBuilder) Build(t testing.TB) config.Cfg { cfg := gc.cfg if cfg.SocketPath == "" { - cfg.SocketPath = "it is a stub to bypass Validate method" + cfg.SocketPath = UnconfiguredSocketPath } root := testhelper.TempDir(t) |