Commit c9709639 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

configexpress: basic tests

With all the capturing that Heptapod does, it is worth
checking that configexpress actually works (renders client
side through data sent with bundles).
parent bb6839826f8a
Pipeline #18556 passed with stage
in 23 minutes and 54 seconds
......@@ -15,6 +15,7 @@ The tests need a working `hg` executable, available on `$PATH`, with the
following extensions available:
- evolve and topic: [hg-evolve](https://pypi.org/project/hg-evolve) ≥ 9.3.0
- configexpress: [hg-configexpress](https://pypi.org/project/hg-configexpress)
#### Test harness (Selenium)
......
from .utils import (
needs,
)
from .utils.hg import LocalRepo
# TODO make a fixture from that:
from .test_push import prepare_simple_repo
ENABLE_CONFIG_EXPRESS = ('--config', 'extensions.configexpress=')
DISABLE_CONFIG_EXPRESS = ('--config', 'extensions.configexpress=!')
def test_configexpress_no_proposition(test_project, tmpdir):
"""Check configexpress output from the client-side (always on stderr)
"""
url = test_project.owner_basic_auth_url
clone = LocalRepo.clone(url, tmpdir.join('repo2'))
prepare_simple_repo(test_project, tmpdir.join('repo1'))
# let's control what GitLab really sees
# for this test, we don't want to depend on the fact that the current
# version of configexpress does not care whether the repo is empty or not
assert test_project.api_branch_titles() == {
'branch/default': 'Commit 0',
'topic/default/zetop': 'Commit 1',
}
# a client without configexpress doesn't see anything special
code, _, err = clone.hg_unchecked('pull', *DISABLE_CONFIG_EXPRESS)
assert code == 0
assert not err.strip()
code, _, err = clone.hg_unchecked('pull', *ENABLE_CONFIG_EXPRESS)
assert code == 0
assert not err.strip()
@needs.fs_access
def test_configexpress_server_proposition(test_project, tmpdir):
"""Check configexpress output from the client-side (always on stderr)
"""
# we don't even need content in the server-side repo
clone = LocalRepo.clone(test_project.owner_basic_auth_url,
tmpdir.join('clone'))
suggestions = ("[express-suggestions]\n", "animal=ant\n")
test_project.put_hgrc(suggestions, file_path='express.hgrc')
test_project.extend_hgrc("\n",
"[configexpress:server2client]\n",
"express-suggestions=express.hgrc\n"
)
# a client without configexpress doesn't see anything special
code, _, err = clone.hg_unchecked('pull', *DISABLE_CONFIG_EXPRESS)
assert code == 0
assert not err.strip()
code, _, err = clone.hg_unchecked('pull', *ENABLE_CONFIG_EXPRESS)
assert code == 0
lines = err.splitlines()
# skip preamble without relying on its contents nor its length
while suggestions[0].strip() != lines[0].strip():
lines = lines[1:]
assert lines, "Did not detect configexpress output"
assert all(got.strip() == expected.strip()
for got, expected in zip(lines, suggestions))
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