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

CommitService.ListFiles: add gitaly comparison tests

parent 681f5ef1
No related branches found
No related tags found
1 merge request!50commitService: implement ListFiles
Pipeline #20311 passed
......@@ -8,6 +8,7 @@
import pytest
import re
from hgitaly.stub.commit_pb2 import (
ListFilesRequest,
ListLastCommitsForTreeRequest,
RawBlameRequest,
)
......@@ -190,3 +191,62 @@
do_rpc('git', ctx1.hex(), b'')
assert exc_info_hg.value.code() == exc_info_git.value.code()
assert exc_info_hg.value.details() == exc_info_git.value.details()
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")
git_shas = {
ctx0.hex(): git_repo.branches()[b'branch/default']['sha'],
}
sub = (wrapper.path / 'sub')
sub.mkdir()
subdir = (sub / 'dir')
subdir.mkdir()
(sub / 'bar').write_text('bar content')
(sub / 'ba2').write_text('ba2 content')
(subdir / 'bar').write_text('bar content')
(subdir / 'ba2').write_text('ba2 content')
# TODO OS indep for paths (actually TODO make wrapper.commit easier to
# use, e.g., check how to make it accept patterns)
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')
# mirror worked
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
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)
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