Commit f0c0cbe9 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

RefService.DeleteRefs: new shortcut in Gitaly comparison tests

This `assert_compare()` makes for shorter assertion lines,
whose meaning is hopefully quicker to grasp.

--HG--
branch : stable
parent 2fc9ad940311
......@@ -66,7 +66,6 @@ def test_delete_refs(gitaly_comparison):
vcs_channels = dict(git=RefServiceStub(fixture.gitaly_channel),
hg=RefServiceStub(fixture.hgitaly_channel))
vcses = vcs_channels.keys()
base_hg_ctx = hg_wrapper.commit_file('foo')
# TODO get_branch_sha does not work because of PosixPath not having
......@@ -93,6 +92,9 @@ def test_delete_refs(gitaly_comparison):
refs=refs,
except_with_prefix=except_prefixes))
def assert_compare(**kw):
assert do_rpc('hg', **kw) == do_rpc('git', **kw)
with pytest.raises(grpc.RpcError) as exc_info_hg:
do_rpc('hg', refs=[b'xy'], except_prefixes=[b'refs/heads'])
......@@ -101,16 +103,15 @@ def test_delete_refs(gitaly_comparison):
assert exc_info_hg.value.details() == exc_info_git.value.details()
hg_resp, git_resp = [do_rpc(vcs, refs=[mr_ref_path]) for vcs in vcses]
assert hg_resp == git_resp
assert_compare(refs=[mr_ref_path])
# unknown refs dont create errors
unknown = b'refs/environments/imaginary'
assert do_rpc('hg', refs=[unknown]) == do_rpc('git', refs=[unknown])
assert_compare(refs=[unknown])
# also mixing unknown with known is ok
setup_mr_ref()
assert do_rpc('hg', refs=mixed_refs) == do_rpc('git', refs=mixed_refs)
assert_compare(refs=[unknown, mr_ref_path])
assert git_repo.all_refs() == {b'refs/heads/branch/default': git_sha}
# TODO use the future wrapper.reload()
......
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