1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2025-06-06 09:34:00 +00:00
TheLocehiliosan_yadm/test/test_unit_report_invalid_alts.py
Erik Flodin 66e509d2e4
Don't always run auto-alt (and -perms) after invoking git command
Improve performance (#505) by only running auto-alt (and auto-perms)
when HEAD has changed after calling a git command, e.g. after committing
or pulling new changes.

Also use this new information to remove stale symlinks when an alt file
has been removed.
2025-04-06 20:57:34 +02:00

32 lines
860 B
Python

"""Unit tests: report_invalid_alts"""
import pytest
@pytest.mark.parametrize("valid", [True, False], ids=["valid", "no_valid"])
@pytest.mark.parametrize("previous", [True, False], ids=["prev", "no_prev"])
def test_report_invalid_alts(runner, yadm, valid, previous):
"""Use report_invalid_alts"""
lwi = ""
alts = "INVALID_ALT=()"
if previous:
lwi = "LEGACY_WARNING_ISSUED=1"
if not valid:
alts = 'INVALID_ALT=("file##invalid")'
script = f"""
YADM_TEST=1 source {yadm}
{lwi}
{alts}
report_invalid_alts
"""
run = runner(command=["bash"], inp=script)
assert run.success == (valid and not previous)
assert run.out == ""
if not valid and not previous:
assert "WARNING" in run.err
assert "file##invalid" in run.err
else:
assert run.err == ""