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

Gitaly Comparison test_compare_find_branch: rewrote with RpcHelper

parent 9cee95b5
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
......@@ -4,7 +4,6 @@
# GNU General Public License version 2 or any later version.
#
# SPDX-License-Identifier: GPL-2.0-or-later
import grpc
import pytest
from hgext3rd.heptapod.special_ref import (
......@@ -26,8 +25,6 @@
def test_compare_find_branch(gitaly_comparison):
fixture = gitaly_comparison
hgitaly_repo = fixture.hgitaly_repo
gitaly_repo = fixture.gitaly_repo
git_repo = fixture.git_repo
fixture.hg_repo_wrapper.write_commit('foo', message="Some foo")
......@@ -31,5 +28,6 @@
git_repo = fixture.git_repo
fixture.hg_repo_wrapper.write_commit('foo', message="Some foo")
gl_branch = b'branch/default'
# mirror worked
......@@ -34,12 +32,4 @@
# mirror worked
assert git_repo.branch_titles() == {b'branch/default': b"Some foo"}
gl_branch = b'branch/default'
hgitaly_request = FindBranchRequest(repository=hgitaly_repo,
name=gl_branch)
gitaly_request = FindBranchRequest(repository=gitaly_repo, name=gl_branch)
gitaly_ref_stub = RefServiceStub(fixture.gitaly_channel)
hgitaly_ref_stub = RefServiceStub(fixture.hgitaly_channel)
assert git_repo.branch_titles() == {gl_branch: b"Some foo"}
......@@ -45,4 +35,11 @@
hg_resp = hgitaly_ref_stub.FindBranch(hgitaly_request)
git_resp = gitaly_ref_stub.FindBranch(gitaly_request)
def response_ignores(resp):
commit = resp.branch.target_commit
# TODO tree_id should be replaced by HGitaly standard value
# once HGitaly2 is the norm
commit.tree_id = ''
# Git adds a line ending
# hg-git adds a branch marker
commit.body = b''
commit.body_size = 0
......@@ -48,14 +45,13 @@
# responses should be identical, except for commit ids
hg_resp.branch.target_commit.id = ''
git_resp.branch.target_commit.id = ''
# right now, this assertion fails because
# - we don't provide a body_size
# - we don't give the explicit "+0000" timezone (but Gitaly does)
# assert hg_resp == git_resp
# Lets' still assert something that works:
assert all(resp.branch.target_commit.subject == b"Some foo"
for resp in (hg_resp, git_resp))
rpc_helper = fixture.rpc_helper(
stub_cls=RefServiceStub,
method_name='FindBranch',
request_cls=FindBranchRequest,
response_sha_attrs=['branch.target_commit.id'],
normalizer=response_ignores,
)
rpc_helper.assert_compare(name=gl_branch)
def test_compare_find_local_branches(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