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>2017-07-10 19:17:51 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-07-10 19:17:51 +0300
commit195a6c079f2e947ec5b5ea51634af30eac778aa1 (patch)
treefb02ec3ca7f1ebf1f5314c9aeb20b7ed89ed3fbc /internal/helper/repo_test.go
parent63f5544b7fd70aa09e676a46bb3527b5622a7f91 (diff)
Also check for "refs" folder for repo existence
Diffstat (limited to 'internal/helper/repo_test.go')
-rw-r--r--internal/helper/repo_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/helper/repo_test.go b/internal/helper/repo_test.go
index e826f0bb2..d92886eb4 100644
--- a/internal/helper/repo_test.go
+++ b/internal/helper/repo_test.go
@@ -1,6 +1,8 @@
package helper
import (
+ "os"
+ "path"
"testing"
"gitlab.com/gitlab-org/gitaly/internal/config"
@@ -129,3 +131,26 @@ func TestGetRepoPath(t *testing.T) {
assert.Equal(t, tc.path, path, tc.desc)
}
}
+
+func assertInvalidRepoWithoutFile(t *testing.T, repo *pb.Repository, repoPath, file string) {
+ oldRoute := path.Join(repoPath, file)
+ renamedRoute := path.Join(repoPath, file+"moved")
+ os.Rename(oldRoute, renamedRoute)
+ defer func() {
+ os.Rename(renamedRoute, oldRoute)
+ }()
+
+ _, err := GetRepoPath(repo)
+
+ testhelper.AssertGrpcError(t, err, codes.NotFound, "")
+}
+
+func TestGetRepoPathWithCorruptedRepo(t *testing.T) {
+ testRepo := testhelper.TestRepository()
+ testRepoStoragePath := testhelper.GitlabTestStoragePath()
+ testRepoPath := path.Join(testRepoStoragePath, testRepo.RelativePath)
+
+ for _, file := range []string{"objects", "refs", "HEAD"} {
+ assertInvalidRepoWithoutFile(t, testRepo, testRepoPath, file)
+ }
+}