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:57:56 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2021-04-29 22:13:52 +0300
commit899ad8910cd6555d453a482305376a3e4ab41ff8 (patch)
treed141a6048adb734b92d14ba66de966aafcad2fc9
parenta4daa51dd6fe7e7cfb631c4379e88d71d70f2b67 (diff)
Replace MustRunCommand with Exec in RequireTree
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/tree.go8
-rw-r--r--internal/git2go/apply_test.go2
-rw-r--r--internal/git2go/commit_test.go2
-rw-r--r--internal/gitaly/service/operations/commit_files_test.go4
4 files changed, 8 insertions, 8 deletions
diff --git a/internal/git/gittest/tree.go b/internal/git/gittest/tree.go
index c8299274f..327ed3ab7 100644
--- a/internal/git/gittest/tree.go
+++ b/internal/git/gittest/tree.go
@@ -5,7 +5,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
- "gitlab.com/gitlab-org/gitaly/internal/testhelper"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
)
// TreeEntry represents an entry of a git tree object.
@@ -20,12 +20,12 @@ type TreeEntry struct {
// RequireTree looks up the given treeish and asserts that its entries match
// the given expected entries. Tree entries are checked recursively.
-func RequireTree(t testing.TB, repoPath, treeish string, expectedEntries []TreeEntry) {
+func RequireTree(t testing.TB, cfg config.Cfg, repoPath, treeish string, expectedEntries []TreeEntry) {
t.Helper()
var actualEntries []TreeEntry
- output := bytes.TrimSpace(testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "ls-tree", "-r", treeish))
+ output := bytes.TrimSpace(Exec(t, cfg, "-C", repoPath, "ls-tree", "-r", treeish))
if len(output) > 0 {
for _, line := range bytes.Split(output, []byte("\n")) {
@@ -36,7 +36,7 @@ func RequireTree(t testing.TB, repoPath, treeish string, expectedEntries []TreeE
actualEntries = append(actualEntries, TreeEntry{
Mode: string(spaceSplit[0]),
Path: path,
- Content: string(testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "show", treeish+":"+path)),
+ Content: string(Exec(t, cfg, "-C", repoPath, "show", treeish+":"+path)),
})
}
}
diff --git a/internal/git2go/apply_test.go b/internal/git2go/apply_test.go
index 47bcd39e2..f67052ca7 100644
--- a/internal/git2go/apply_test.go
+++ b/internal/git2go/apply_test.go
@@ -215,7 +215,7 @@ func TestExecutor_Apply(t *testing.T) {
Committer: committer,
Message: tc.patches[len(tc.patches)-1].Message,
}, getCommit(t, ctx, repo, commitID))
- gittest.RequireTree(t, repoPath, commitID.String(), tc.tree)
+ gittest.RequireTree(t, cfg, repoPath, commitID.String(), tc.tree)
})
}
}
diff --git a/internal/git2go/commit_test.go b/internal/git2go/commit_test.go
index 26c8480fc..7f0784084 100644
--- a/internal/git2go/commit_test.go
+++ b/internal/git2go/commit_test.go
@@ -492,7 +492,7 @@ func TestExecutor_Commit(t *testing.T) {
Message: message,
}, getCommit(t, ctx, repo, commitID))
- gittest.RequireTree(t, repoPath, commitID.String(), step.treeEntries)
+ gittest.RequireTree(t, cfg, repoPath, commitID.String(), step.treeEntries)
parentCommit = commitID
}
})
diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go
index 27c06e124..db448dcc5 100644
--- a/internal/gitaly/service/operations/commit_files_test.go
+++ b/internal/gitaly/service/operations/commit_files_test.go
@@ -929,7 +929,7 @@ func TestUserCommitFiles(t *testing.T) {
require.Equal(t, step.branchCreated, resp.BranchUpdate.BranchCreated, "step %d", i+1)
require.Equal(t, step.repoCreated, resp.BranchUpdate.RepoCreated, "step %d", i+1)
- gittest.RequireTree(t, repoPath, branch, step.treeEntries)
+ gittest.RequireTree(t, cfg, repoPath, branch, step.treeEntries)
}
})
}
@@ -967,7 +967,7 @@ func TestUserCommitFilesStableCommitID(t *testing.T) {
require.Equal(t, resp.BranchUpdate.CommitId, "4f0ca1fbf05e04dbd5f68d14677034e0afee58ff")
require.True(t, resp.BranchUpdate.BranchCreated)
require.True(t, resp.BranchUpdate.RepoCreated)
- gittest.RequireTree(t, repoPath, "refs/heads/master", []gittest.TreeEntry{
+ gittest.RequireTree(t, cfg, repoPath, "refs/heads/master", []gittest.TreeEntry{
{Mode: "100644", Path: "file.txt", Content: "content"},
})