Skip to content
Snippets Groups Projects
Commit 71ea3ec0 authored by Georges Racinet's avatar Georges Racinet
Browse files

Gitaly Comparison test_list_files: rewrote with RpcHelper

This one is very direct.
parent 9dd880f0
No related branches found
No related tags found
2 merge requests!81Merge stable into default,!80Switching Gitaly Comparison test_ref and test_commit to new style
......@@ -149,8 +149,7 @@
def test_compare_list_files(gitaly_comparison):
fixture = gitaly_comparison
repo_message = fixture.gitaly_repo
git_repo = fixture.git_repo
wrapper = fixture.hg_repo_wrapper
ctx0 = wrapper.write_commit('foo', message="Some foo")
......@@ -153,10 +152,7 @@
git_repo = fixture.git_repo
wrapper = fixture.hg_repo_wrapper
ctx0 = wrapper.write_commit('foo', message="Some foo")
git_shas = {
ctx0.hex(): git_repo.branches()[b'branch/default']['sha'],
}
sub = (wrapper.path / 'sub')
sub.mkdir()
......@@ -171,7 +167,6 @@
ctx1 = wrapper.commit(rel_paths=['sub/bar', 'sub/ba2',
'sub/dir/bar', 'sub/dir/ba2'],
message="zebar", add_remove=True)
git_shas[ctx1.hex()] = git_repo.branches()[b'branch/default']['sha']
ctx2 = wrapper.write_commit('sub/bar', message='default head')
ctx3 = wrapper.write_commit('zoo', parent=ctx0, branch='other',
message='other head')
......@@ -180,26 +175,14 @@
git_branches = git_repo.branches()
assert set(git_branches) == {b'branch/default', b'branch/other'}
# TODO check if we can access the hg-git map, would be easier
git_shas[ctx2.hex()] = git_branches[b'branch/default']['sha']
git_shas[ctx3.hex()] = git_branches[b'branch/other']['sha']
commit_stubs = dict(git=CommitServiceStub(fixture.gitaly_channel),
hg=CommitServiceStub(fixture.hgitaly_channel))
def do_rpc(vcs, rev):
if vcs == 'git' and len(rev) == 40:
# defaulting useful for tests of unknown revs
rev = git_shas.get(rev, rev)
request = ListFilesRequest(
repository=repo_message,
revision=rev)
response = commit_stubs[vcs].ListFiles(request)
final = []
for resp in response:
final.extend(resp.paths)
return final
rpc_helper = fixture.rpc_helper(
stub_cls=CommitServiceStub,
method_name='ListFiles',
request_cls=ListFilesRequest,
streaming=True,
request_sha_attrs=['revision'],
)
not_exists = b'65face65' * 5
for rev in [ctx0.hex(), ctx1.hex(), ctx2.hex(), ctx3.hex(),
not_exists, b'branch/default', b'branch/other']:
......@@ -202,8 +185,8 @@
not_exists = b'65face65' * 5
for rev in [ctx0.hex(), ctx1.hex(), ctx2.hex(), ctx3.hex(),
not_exists, b'branch/default', b'branch/other']:
assert do_rpc('hg', rev) == do_rpc('git', rev)
rpc_helper.assert_compare(revision=rev)
def test_compare_find_commits(gitaly_comparison):
......
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