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:
authorJohn Cai <jcai@gitlab.com>2022-07-20 20:07:21 +0300
committerJohn Cai <jcai@gitlab.com>2022-08-02 17:22:29 +0300
commit0b89c482733252240890bf5384cecccf4d414d69 (patch)
tree1f6a5c26559303e5c766967023d1c64ce9e4c069
parent8735eec2693fa8ff0ea9b1f351f1910a25223d1e (diff)
gittest: Extract gitSupportsStatusFlushing to an exported method
The logic of gitSupportsStatusFlushing is useful beyond the updateref package. Extract this to its own method in the gittest package.
-rw-r--r--internal/git/gittest/command_factory.go10
-rw-r--r--internal/git/updateref/updateref_test.go12
2 files changed, 13 insertions, 9 deletions
diff --git a/internal/git/gittest/command_factory.go b/internal/git/gittest/command_factory.go
index 0285a1f9c..25d76f6a6 100644
--- a/internal/git/gittest/command_factory.go
+++ b/internal/git/gittest/command_factory.go
@@ -1,6 +1,7 @@
package gittest
import (
+ "context"
"testing"
"github.com/stretchr/testify/require"
@@ -16,3 +17,12 @@ func NewCommandFactory(tb testing.TB, cfg config.Cfg, opts ...git.ExecCommandFac
tb.Cleanup(cleanup)
return factory
}
+
+// GitSupportsStatusFlushing returns whether or not the current version of Git
+// supports status flushing.
+//nolint: revive
+func GitSupportsStatusFlushing(t *testing.T, ctx context.Context, cfg config.Cfg) bool {
+ version, err := NewCommandFactory(t, cfg).GitVersion(ctx)
+ require.NoError(t, err)
+ return version.FlushesUpdaterefStatus()
+}
diff --git a/internal/git/updateref/updateref_test.go b/internal/git/updateref/updateref_test.go
index 0de5f698c..296646880 100644
--- a/internal/git/updateref/updateref_test.go
+++ b/internal/git/updateref/updateref_test.go
@@ -128,7 +128,7 @@ func TestUpdater_concurrentLocking(t *testing.T) {
cfg, protoRepo, _ := testcfg.BuildWithRepo(t)
ctx := testhelper.Context(t)
- if !gitSupportsStatusFlushing(t, ctx, cfg) {
+ if !gittest.GitSupportsStatusFlushing(t, ctx, cfg) {
t.Skip("git does not support flushing yet, which is known to be flaky")
}
@@ -204,7 +204,7 @@ func TestUpdater_cancel(t *testing.T) {
cfg, repo, updater := setupUpdater(t, ctx)
- if !gitSupportsStatusFlushing(t, ctx, cfg) {
+ if !gittest.GitSupportsStatusFlushing(t, ctx, cfg) {
t.Skip("git does not support flushing yet, which is known to be flaky")
}
@@ -267,7 +267,7 @@ func TestUpdater_capturesStderr(t *testing.T) {
require.NoError(t, updater.Update(git.ReferenceName(ref), newValue, oldValue))
var expectedErr string
- if gitSupportsStatusFlushing(t, ctx, cfg) {
+ if gittest.GitSupportsStatusFlushing(t, ctx, cfg) {
expectedErr = fmt.Sprintf("state update to \"commit\" failed: EOF, stderr: \"fatal: commit: cannot update ref '%s': "+
"trying to write ref '%s' with nonexistent object %s\\n\"", ref, ref, newValue)
} else {
@@ -280,9 +280,3 @@ func TestUpdater_capturesStderr(t *testing.T) {
require.NotNil(t, err)
require.Equal(t, err.Error(), expectedErr)
}
-
-func gitSupportsStatusFlushing(t *testing.T, ctx context.Context, cfg config.Cfg) bool {
- version, err := gittest.NewCommandFactory(t, cfg).GitVersion(ctx)
- require.NoError(t, err)
- return version.FlushesUpdaterefStatus()
-}