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-04-27 19:40:57 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2021-04-29 22:13:52 +0300
commitcf439642cae08dd4dab6a88bd026e8dedbff12d1 (patch)
treee5a10f868176243f04a6ce2c03f2fa15f7142523
parenta0fa75631fef25691086fdc7f1a4268bc6e26cd7 (diff)
Replace MustRunCommand with Exec in RemoteExists
Usages of the MustRunCommand replaced with Exec in order to break dependency on the global config.Config variable. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-rw-r--r--internal/git/gittest/remote.go6
-rw-r--r--internal/git/objectpool/link_test.go8
-rw-r--r--internal/gitaly/service/objectpool/link_test.go6
3 files changed, 10 insertions, 10 deletions
diff --git a/internal/git/gittest/remote.go b/internal/git/gittest/remote.go
index e4bbd4f9c..6b82665d7 100644
--- a/internal/git/gittest/remote.go
+++ b/internal/git/gittest/remote.go
@@ -4,16 +4,16 @@ import (
"strings"
"testing"
- "gitlab.com/gitlab-org/gitaly/internal/testhelper"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
)
// RemoteExists tests if the repository at repoPath has a Git remote named remoteName.
-func RemoteExists(t testing.TB, repoPath string, remoteName string) bool {
+func RemoteExists(t testing.TB, cfg config.Cfg, repoPath string, remoteName string) bool {
if remoteName == "" {
t.Fatal("empty remote name")
}
- remotes := testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "remote")
+ remotes := Exec(t, cfg, "-C", repoPath, "remote")
for _, r := range strings.Split(string(remotes), "\n") {
if r == remoteName {
return true
diff --git a/internal/git/objectpool/link_test.go b/internal/git/objectpool/link_test.go
index faa8dd1f7..7157df5ee 100644
--- a/internal/git/objectpool/link_test.go
+++ b/internal/git/objectpool/link_test.go
@@ -42,7 +42,7 @@ func TestLink(t *testing.T) {
require.Equal(t, content, newContent)
- require.False(t, gittest.RemoteExists(t, pool.FullPath(), testRepo.GetGlRepository()), "pool remotes should not include %v", testRepo)
+ require.False(t, gittest.RemoteExists(t, pool.cfg, pool.FullPath(), testRepo.GetGlRepository()), "pool remotes should not include %v", testRepo)
}
func TestLinkRemoveBitmap(t *testing.T) {
@@ -101,10 +101,10 @@ func TestUnlink(t *testing.T) {
require.NoError(t, pool.Create(ctx, testRepo), "create pool")
require.NoError(t, pool.Link(ctx, testRepo), "link test repo to pool")
- require.False(t, gittest.RemoteExists(t, pool.FullPath(), testRepo.GetGlRepository()), "pool remotes should include %v", testRepo)
+ require.False(t, gittest.RemoteExists(t, pool.cfg, pool.FullPath(), testRepo.GetGlRepository()), "pool remotes should include %v", testRepo)
require.NoError(t, pool.Unlink(ctx, testRepo), "unlink repo")
- require.False(t, gittest.RemoteExists(t, pool.FullPath(), testRepo.GetGlRepository()), "pool remotes should no longer include %v", testRepo)
+ require.False(t, gittest.RemoteExists(t, pool.cfg, pool.FullPath(), testRepo.GetGlRepository()), "pool remotes should no longer include %v", testRepo)
}
func TestLinkAbsoluteLinkExists(t *testing.T) {
@@ -137,5 +137,5 @@ func TestLinkAbsoluteLinkExists(t *testing.T) {
testRepoObjectsPath := filepath.Join(testRepoPath, "objects")
require.Equal(t, fullPath, filepath.Join(testRepoObjectsPath, string(content)), "the content of the alternates file should be the relative version of the absolute pat")
- require.True(t, gittest.RemoteExists(t, pool.FullPath(), "origin"), "pool remotes should include %v", testRepo)
+ require.True(t, gittest.RemoteExists(t, pool.cfg, pool.FullPath(), "origin"), "pool remotes should include %v", testRepo)
}
diff --git a/internal/gitaly/service/objectpool/link_test.go b/internal/gitaly/service/objectpool/link_test.go
index 2ca1dfd36..2b0576958 100644
--- a/internal/gitaly/service/objectpool/link_test.go
+++ b/internal/gitaly/service/objectpool/link_test.go
@@ -201,8 +201,8 @@ func TestUnlink(t *testing.T) {
require.NoError(t, pool2.Remove(ctx))
}()
- require.False(t, gittest.RemoteExists(t, pool.FullPath(), repo.GlRepository), "sanity check: remote exists in pool")
- require.False(t, gittest.RemoteExists(t, pool.FullPath(), deletedRepo.GlRepository), "sanity check: remote exists in pool")
+ require.False(t, gittest.RemoteExists(t, cfg, pool.FullPath(), repo.GlRepository), "sanity check: remote exists in pool")
+ require.False(t, gittest.RemoteExists(t, cfg, pool.FullPath(), deletedRepo.GlRepository), "sanity check: remote exists in pool")
testCases := []struct {
desc string
@@ -276,7 +276,7 @@ func TestUnlink(t *testing.T) {
require.NoError(t, err, "call UnlinkRepositoryFromObjectPool")
remoteName := tc.req.Repository.GlRepository
- require.False(t, gittest.RemoteExists(t, pool.FullPath(), remoteName), "remote should no longer exist in pool")
+ require.False(t, gittest.RemoteExists(t, cfg, pool.FullPath(), remoteName), "remote should no longer exist in pool")
})
}
}