diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-03-23 09:36:20 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-03-23 09:38:53 +0300 |
commit | f7b7930ae71796676d168e1d6e2ffa16cc57cb8d (patch) | |
tree | cc79fc547a96f7e595264ba0aa18124b0165354d | |
parent | e9c85a7455f1934bbebf589db4e9600a45c8f1bb (diff) |
git: Fix bundled Git test relying on state of feature flag
One of our tests for bundled Git verifies that the command factory is
setting up the execution environment as expected. This test implicitly
relies on the state of feature flags though because it assumes that all
bundled Git constructors are usable. This worked alright by pure chance:
the feature flag for this bundled Git constructor is always true because
we use `math.Rand()` to set the flag's value, which isn't ever properly
seeded.
Fix this issue by hard-coding the feature flag value to `true` so that
the test doesn't break when the randomly injected value changes.
-rw-r--r-- | internal/git/command_factory_test.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go index f960c2c2e..067dace1e 100644 --- a/internal/git/command_factory_test.go +++ b/internal/git/command_factory_test.go @@ -17,6 +17,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v14/internal/helper/text" + "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper" "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg" ) @@ -180,6 +181,10 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) { }) t.Run("set using GITALY_TESTING_BUNDLED_GIT_PATH", func(t *testing.T) { + // Force use of Git v2.35.1 so that we can easily handle the expected suffix. + ctx := featureflag.ContextWithFeatureFlag(ctx, featureflag.GitV2351WithFetchSpeedups, true) + suffix := "-v2.35.1.gl1" + bundledGitDir := testhelper.TempDir(t) var bundledGitConstructors []git.BundledGitEnvironmentConstructor @@ -191,8 +196,6 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) { } require.NotEmpty(t, bundledGitConstructors) - suffix := bundledGitConstructors[0].Suffix - bundledGitExecutable := filepath.Join(bundledGitDir, "gitaly-git"+suffix) bundledGitRemoteExecutable := filepath.Join(bundledGitDir, "gitaly-git-remote-http"+suffix) |