Commit 3bbd107a authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

test_project_mirror: with or without bookmarks

parent 7521c0c4c45e
Pipeline #14936 waiting for manual action with stages
in 25 seconds
......@@ -4,7 +4,12 @@
# GNU General Public License version 2 or any later version.
#
# SPDX-License-Identifier: GPL-2.0-or-later
from .test_import import prepare_import_source, LocalRepo, hg_log_set
import pytest
from .utils.hg import LocalRepo, assert_matching_changesets
from .test_import import prepare_import_source
parametrize = pytest.mark.parametrize
def test_create(test_project):
......@@ -54,6 +59,47 @@ def test_pull(test_project, public_project, tmpdir):
clone = LocalRepo.clone(test_project.owner_basic_auth_url,
tmpdir.join('target-repo'))
assert_matching_changesets(clone, src_repo, ('node', 'desc'))
@parametrize('bookmarks', ('with', 'without'))
def test_pull_bookmarks(test_project, public_project, tmpdir, bookmarks):
"""Test hg-pull mirror"""
with_bookmarks = bookmarks == 'with'
if with_bookmarks:
test_project.owner_api_hgrc_set(inherit=True, allow_bookmarks=True)
src_repo, src_url = prepare_import_source(public_project, tmpdir,
tweak_hgrc=False)
public_project.owner_api_hgrc_set(inherit=True, allow_bookmarks=True)
src_repo.hg('bookmark', '-r', '0', 'book1')
src_repo.hg('push', '-B', 'book1', expected_return_code=1)
print("Graph of source project after push:")
print(src_repo.graphlog())
print("Url of the mirror target")
print(src_url)
mirror = test_project.api_create_mirror(url=src_url,
enabled=True,
hg_mirror_type='hg-pull')
res = mirror.api_trigger(check=False)
assert res.status_code == 204
# Check that Gitlab became aware of the changes done by the pull
test_project.wait_assert_api_branches(
lambda branches: "topic/default/antelope" in branches,
timeout=30,
)
assert ('book1' in test_project.api_branches()) is with_bookmarks
clone = LocalRepo.clone(test_project.owner_basic_auth_url,
tmpdir.join('target-repo'))
fields = ['node', 'desc']
if with_bookmarks:
fields.append('bookmarks')
else:
assert 'no bookmarks' in clone.hg('bookmarks')
expected_log_set = hg_log_set(src_repo, phase=False)
assert hg_log_set(clone, phase=False) == expected_log_set
assert_matching_changesets(clone, src_repo, fields)
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