Skip to content
Snippets Groups Projects
Commit 9290e989 authored by Sushil Khanchi's avatar Sushil Khanchi :koala:
Browse files

CreateRepository: add gitaly comparison tests

parent 25514844
No related branches found
No related tags found
1 merge request!64RepositoryService: implement CreateRepository
......@@ -12,4 +12,5 @@
import grpc
import itertools
# from hgitaly.git import EMPTY_TREE_OID
from hgitaly.stub.shared_pb2 import Repository
from hgitaly.stub.repository_service_pb2 import (
......@@ -15,4 +16,5 @@
from hgitaly.stub.repository_service_pb2 import (
CreateRepositoryRequest,
FindMergeBaseRequest,
)
from hgitaly.stub.repository_service_pb2_grpc import RepositoryServiceStub
......@@ -96,3 +98,43 @@
==
do_rpc('git', [git_shas[sha0], sha_not_exists])
)
def test_create_repository(gitaly_channel, grpc_channel, server_repos_root):
rel_path = 'sample_repo'
default_storage = 'default'
repo_stubs = dict(
hg=RepositoryServiceStub(grpc_channel),
git=RepositoryServiceStub(gitaly_channel)
)
def do_rpc(vcs, rel_path, storage=default_storage):
grpc_repo = Repository(relative_path=rel_path,
storage_name=storage)
request = CreateRepositoryRequest(repository=grpc_repo)
response = repo_stubs[vcs].CreateRepository(request)
return response
# actual test
assert do_rpc('hg', rel_path) == do_rpc('git', rel_path)
# when storage name is invalid
with pytest.raises(grpc.RpcError) as exc_info_hg:
do_rpc('hg', rel_path, storage='cargoship')
with pytest.raises(grpc.RpcError) as exc_info_git:
do_rpc('git', rel_path, storage='cargoship')
assert exc_info_hg.value.code() == exc_info_git.value.code()
assert 'no such storage' in exc_info_hg.value.details()
assert 'no such storage' in exc_info_git.value.details()
# test with a broken symlink (which points to itself)
repo_name = "myrepo_a_broken_symlink"
path = (server_repos_root / default_storage / repo_name)
path.symlink_to(path)
with pytest.raises(grpc.RpcError) as exc_info_hg:
do_rpc('hg', repo_name)
with pytest.raises(grpc.RpcError) as exc_info_git:
do_rpc('git', repo_name)
assert exc_info_hg.value.code() == exc_info_git.value.code()
assert 'Too many levels of symbolic links' in exc_info_hg.value.details()
assert 'file exists' in exc_info_git.value.details()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment