mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-27 18:49:17 +01:00
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (flutter, flutter-analyze, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,flutter-analyze,dependency-freshness) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / lock-popup-safety (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (0) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (1) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (2) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (3) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (4) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (5) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (6) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (7) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (8) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (9) (push) Waiting to run
Tests / flutter-coverage (push) Blocked by required conditions
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
install.sh re-asserted ~/src/utils/gatelock editable on every deploy. That clone sat at 0.16.0 behind the 0.16.2 pin, so the stall-watch fix (c890f31a21) was pushed and deployed but never ran. A clone older than the pin now gets the pinned release instead, and the verify step fails closed when the imported gatelock is older than the pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
96 lines
3.3 KiB
Python
96 lines
3.3 KiB
Python
"""The gatelock version gate install.sh runs (scripts/gatelock_pin.py)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
import pytest
|
|
|
|
from scripts import gatelock_pin as gp
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
PIN = "gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.16.2#subdirectory=gatelock"
|
|
|
|
|
|
def _repo(root: Path, dep: str = PIN) -> Path:
|
|
path = root / "pyproject.toml"
|
|
path.write_text(f'[project]\ndependencies = [\n "{dep}",\n]\n', encoding="utf-8")
|
|
return path
|
|
|
|
|
|
def _clone(root: Path, version: str) -> Path:
|
|
clone = root / "gatelock"
|
|
clone.mkdir()
|
|
(clone / "pyproject.toml").write_text(
|
|
f'[project]\nname = "gatelock"\nversion = "{version}"\n', encoding="utf-8"
|
|
)
|
|
return clone
|
|
|
|
|
|
def test_pinned_version_reads_the_tag(tmp_path: Path) -> None:
|
|
"""The pin's tag is the version."""
|
|
assert gp.pinned_version(_repo(tmp_path)) == (0, 16, 2)
|
|
|
|
|
|
def test_pinned_version_without_a_gatelock_pin(tmp_path: Path) -> None:
|
|
"""No gatelock dependency is an error, not a pass."""
|
|
with pytest.raises(gp.PinError, match="no gatelock"):
|
|
gp.pinned_version(_repo(tmp_path, "requests==2.0.0"))
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("version", "code"), [("0.16.0", 1), ("0.16.2", 0), ("0.17.0", 0)]
|
|
)
|
|
def test_clone_ok_compares_against_the_pin(
|
|
tmp_path: Path, version: str, code: int, caplog: pytest.LogCaptureFixture
|
|
) -> None:
|
|
"""A clone older than the pin must not be made editable."""
|
|
# 2026-11-27: a stale ~/src/utils clone (0.16.0) was re-asserted over the
|
|
# 0.16.2 pin, and the fix never reached the lock.
|
|
repo, clone = _repo(tmp_path), _clone(tmp_path, version)
|
|
assert gp.main(["clone-ok", str(repo), str(clone)]) == code
|
|
if code:
|
|
assert "older than the pin" in caplog.text
|
|
|
|
|
|
def test_clone_ok_unreadable_clone(tmp_path: Path) -> None:
|
|
"""A missing clone fails closed."""
|
|
repo = _repo(tmp_path)
|
|
assert gp.main(["clone-ok", str(repo), str(tmp_path / "missing")]) == gp.EXIT_ERROR
|
|
|
|
|
|
def test_installed_ok(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
"""The imported gatelock is checked against the pin."""
|
|
repo = _repo(tmp_path)
|
|
monkeypatch.setattr(gp, "installed_version", lambda: (0, 16, 2))
|
|
assert gp.main(["installed-ok", str(repo)]) == gp.EXIT_OK
|
|
monkeypatch.setattr(gp, "installed_version", lambda: (0, 16, 0))
|
|
assert gp.main(["installed-ok", str(repo)]) == 1
|
|
|
|
|
|
def test_installed_version_is_the_running_one() -> None:
|
|
"""The real metadata lookup returns a version."""
|
|
assert gp.installed_version() >= (0, 1, 0)
|
|
|
|
|
|
def test_spec_prints_the_pin(
|
|
tmp_path: Path, capsys: pytest.CaptureFixture[str]
|
|
) -> None:
|
|
"""Spec prints the exact pinned dependency for pip."""
|
|
assert gp.main(["spec", str(_repo(tmp_path))]) == gp.EXIT_OK
|
|
assert capsys.readouterr().out.strip() == PIN
|
|
|
|
|
|
def test_bad_usage(tmp_path: Path) -> None:
|
|
"""Unknown or short commands are usage errors."""
|
|
assert gp.main(["nope"]) == gp.EXIT_ERROR
|
|
assert gp.main(["clone-ok", str(_repo(tmp_path))]) == gp.EXIT_ERROR
|
|
|
|
|
|
def test_bad_version_text(tmp_path: Path) -> None:
|
|
"""A non-numeric version fails closed."""
|
|
repo, clone = _repo(tmp_path), _clone(tmp_path, "abc")
|
|
assert gp.main(["clone-ok", str(repo), str(clone)]) == gp.EXIT_ERROR
|