diff options
author | Alejandro Rodríguez <alejorro70@gmail.com> | 2017-06-06 00:39:24 +0300 |
---|---|---|
committer | Alejandro Rodríguez <alejorro70@gmail.com> | 2017-06-14 22:25:46 +0300 |
commit | e19655208349c6b22194759997d7581012825aca (patch) | |
tree | 626b3e176643492fe40fcd134d09557c4e2cf577 /internal/helper/repo_test.go | |
parent | e8f0485c7ac1afd2aeb2568fdc477162dc56f852 (diff) |
Stop using deprecated field `path` in Repository messages
Diffstat (limited to 'internal/helper/repo_test.go')
-rw-r--r-- | internal/helper/repo_test.go | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/internal/helper/repo_test.go b/internal/helper/repo_test.go index 29e3daa7b..e826f0bb2 100644 --- a/internal/helper/repo_test.go +++ b/internal/helper/repo_test.go @@ -17,14 +17,18 @@ func TestGetRepoPath(t *testing.T) { config.Config.Storages = oldStorages }(config.Config.Storages) + testRepo := testhelper.TestRepository() + repoPath, err := GetRepoPath(testRepo) + if err != nil { + t.Fatal(err) + } + exampleStorages := []config.Storage{ {Name: "default", Path: testhelper.GitlabTestStoragePath()}, {Name: "other", Path: "/home/git/repositories2"}, {Name: "third", Path: "/home/git/repositories3"}, } - repoPath := testhelper.GitlabTestRepoPath() - testCases := []struct { desc string storages []config.Storage @@ -33,41 +37,13 @@ func TestGetRepoPath(t *testing.T) { err codes.Code }{ { - desc: "storages configured but only repo.Path is provided", - storages: exampleStorages, - repo: &pb.Repository{Path: repoPath}, - path: repoPath, - }, - { - desc: "storages configured, storage name not known, repo.Path provided", - storages: exampleStorages, - repo: &pb.Repository{Path: repoPath, StorageName: "does not exist", RelativePath: "foobar.git"}, - path: repoPath, - }, - { - desc: "no storages configured, repo.Path provided", - repo: &pb.Repository{Path: repoPath, StorageName: "does not exist", RelativePath: testhelper.TestRelativePath}, - path: repoPath, - }, - { - desc: "storages configured, no repo.Path", + desc: "storages configured", storages: exampleStorages, repo: &pb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath}, path: repoPath, }, { - desc: "storage configured, storage name match, repo.Path provided", - storages: exampleStorages, - repo: &pb.Repository{Path: "/foo/bar.git", StorageName: "default", RelativePath: testhelper.TestRelativePath}, - path: repoPath, - }, - { - desc: "no storage config, repo.Path provided", - repo: &pb.Repository{Path: repoPath, StorageName: "default", RelativePath: "bazqux.git"}, - path: repoPath, - }, - { - desc: "no storage config, storage name provided, no repo.Path", + desc: "no storage config, storage name provided", repo: &pb.Repository{StorageName: "does not exist", RelativePath: testhelper.TestRelativePath}, err: codes.InvalidArgument, }, @@ -87,14 +63,16 @@ func TestGetRepoPath(t *testing.T) { err: codes.InvalidArgument, }, { - desc: "empty string repo", - repo: &pb.Repository{Path: ""}, - err: codes.InvalidArgument, + desc: "non existing repo", + storages: exampleStorages, + repo: &pb.Repository{StorageName: "default", RelativePath: "made/up/path.git"}, + err: codes.NotFound, }, { - desc: "non existing repo", - repo: &pb.Repository{Path: "/made/up/path.git"}, - err: codes.NotFound, + desc: "non existing storage", + storages: exampleStorages, + repo: &pb.Repository{StorageName: "does not exists", RelativePath: testhelper.TestRelativePath}, + err: codes.InvalidArgument, }, { desc: "relative path with directory traversal", |