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

Gitaly Comparison test_delete_refs: using `RepoWrapper.reload()`

This is a just-released feature of mercurial-testhelpers.

With the inner functions enclosing the `hg_repo` local variable
we had to systematically redefine `hg_repo` upon each reload() or
stop using that abbreviation. We chose the latter.
parent 2aba198d
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
......@@ -3,4 +3,4 @@
pytest>=3.0.0
pytest-cov
pytest-grpc
mercurial_testhelpers>=0.5.0
mercurial_testhelpers>=0.6.0
......@@ -98,7 +98,6 @@
fixture = gitaly_comparison
git_repo = fixture.git_repo
hg_wrapper = fixture.hg_repo_wrapper
hg_repo = hg_wrapper.repo
base_hg_ctx = hg_wrapper.commit_file('foo')
hg_sha = base_hg_ctx.hex()
......@@ -113,7 +112,6 @@
def setup_mr_ref():
git_repo.write_ref(mr_ref_path.decode(), git_sha)
write_gitlab_special_ref(hg_repo, mr_ref_name, hg_sha)
# invalidation TODO use the future wrapper.reload()
setattr(hg_repo, '_gitlab_refs_special-refs', None)
write_gitlab_special_ref(hg_wrapper.repo, mr_ref_name, hg_sha)
hg_wrapper.reload()
assert mr_ref_path in git_repo.all_refs()
......@@ -119,5 +117,5 @@
assert mr_ref_path in git_repo.all_refs()
assert mr_ref_name in special_refs(hg_repo)
assert mr_ref_name in special_refs(hg_wrapper.repo)
setup_mr_ref()
......@@ -136,9 +134,8 @@
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()
setattr(hg_repo, '_gitlab_refs_special-refs', None)
assert special_refs(hg_repo) == {}
hg_wrapper.reload()
assert special_refs(hg_wrapper.repo) == {}
# using except_with_prefix
env_ref_name = b'environments/2877'
......@@ -146,7 +143,6 @@
def setup_env_ref():
git_repo.write_ref(env_ref_path.decode(), git_sha)
write_gitlab_special_ref(hg_repo, env_ref_name, hg_sha)
# TODO use the future wrapper.reload()
setattr(hg_repo, '_gitlab_refs_special-refs', None)
write_gitlab_special_ref(hg_wrapper.repo, env_ref_name, hg_sha)
hg_wrapper.reload()
assert env_ref_path in git_repo.all_refs()
......@@ -152,5 +148,5 @@
assert env_ref_path in git_repo.all_refs()
assert env_ref_name in special_refs(hg_repo)
assert env_ref_name in special_refs(hg_wrapper.repo)
# on the Mercurial side, we'll consider the special ref only,
# but on the Git side, the `refs/heads` prefix has to be ignored.
......@@ -167,9 +163,8 @@
assert_compare(except_with_prefix=except_prefixes)
assert git_repo.all_refs() == {b'refs/heads/branch/default': git_sha,
env_ref_path: git_sha}
# TODO use the future wrapper.reload()
setattr(hg_repo, '_gitlab_refs_special-refs', None)
assert special_refs(hg_repo) == {env_ref_name: hg_sha}
hg_wrapper.reload()
assert special_refs(hg_wrapper.repo) == {env_ref_name: hg_sha}
def test_find_ref_name(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