Commit 44b9ae37 authored by Sushil Khanchi's avatar Sushil Khanchi 🐨
Browse files

CreateRepository: add gitaly comparison tests

parent 255148442fed
......@@ -12,7 +12,9 @@ import pytest
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 (
from hgitaly.stub.repository_service_pb2_grpc import RepositoryServiceStub
......@@ -96,3 +98,43 @@ def test_compare_find_merge_base(gitaly_comparison):
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(
def do_rpc(vcs, rel_path, storage=default_storage):
grpc_repo = Repository(relative_path=rel_path,
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)
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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment