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:
authorAlejandro Rodríguez <alejorro70@gmail.com>2018-02-06 23:26:30 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-02-27 22:10:00 +0300
commite2ed1aae8562c83293d59262f3e19ad40098fd46 (patch)
treef80d2cde02cbc5386cbdf8de017ea5f726d0ac4f /internal/testhelper
parent6fcc89dc8d0a62e215c2bc596036486113a97442 (diff)
Implement BlobService.GetNewLfsPointers
Diffstat (limited to 'internal/testhelper')
-rw-r--r--internal/testhelper/commit.go38
-rw-r--r--internal/testhelper/testhelper.go2
2 files changed, 39 insertions, 1 deletions
diff --git a/internal/testhelper/commit.go b/internal/testhelper/commit.go
index 5d3cca8da..e0285b6b9 100644
--- a/internal/testhelper/commit.go
+++ b/internal/testhelper/commit.go
@@ -1,6 +1,10 @@
package testhelper
import (
+ "fmt"
+ "os"
+ "os/exec"
+ "path"
"strings"
"testing"
)
@@ -20,3 +24,37 @@ func CreateCommit(t *testing.T, repoPath string, branchName string) string {
MustRunCommand(t, nil, "git", "-C", repoPath, "update-ref", "refs/heads/"+branchName, newCommitID)
return newCommitID
}
+
+// CreateCommitInAlternateObjectDirectory runs a command such that its created
+// objects will live in an alternate objects directory. It returns the current
+// head after the command is run and the alternate objects directory path
+func CreateCommitInAlternateObjectDirectory(t *testing.T, repoPath string, cmd *exec.Cmd) (currentHead []byte, altObjectsDir string) {
+ gitPath := path.Join(repoPath, ".git")
+ altObjectsDir = "./alt-objects"
+
+ altObjectsPath := path.Join(gitPath, altObjectsDir)
+ gitObjectEnv := []string{
+ fmt.Sprintf("GIT_OBJECT_DIRECTORY=%s", altObjectsPath),
+ fmt.Sprintf("GIT_ALTERNATE_OBJECT_DIRECTORIES=%s", path.Join(gitPath, "objects")),
+ }
+ if err := os.Mkdir(altObjectsPath, 0777); err != nil {
+ t.Fatal(err)
+ }
+
+ // Because we set 'gitObjectEnv', the new objects created by this command
+ // will go into 'find-commits-alt-test-repo/.git/alt-objects'.
+ cmd.Env = gitObjectEnv
+ if output, err := cmd.Output(); err != nil {
+ stderr := err.(*exec.ExitError).Stderr
+ t.Fatalf("stdout: %s, stderr: %s", output, stderr)
+ }
+
+ cmd = exec.Command("git", "-C", repoPath, "rev-parse", "HEAD")
+ cmd.Env = gitObjectEnv
+ currentHead, err := cmd.Output()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ return currentHead[:len(currentHead)-1], altObjectsDir
+}
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index 52cea227c..980d1040f 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -139,7 +139,7 @@ func AssertGrpcError(t *testing.T, err error, expectedCode codes.Code, containsT
}
if containsText != "" && !strings.Contains(err.Error(), containsText) {
- t.Fatal(err)
+ t.Fatalf("Expected an error message containing %v, got %v", containsText, err.Error())
}
}