mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 14:30:52 +00:00
Merge branch 'main' into feature/store-i18n
Conflicts resolved: - Dockerfile: keep HEAD; filesystem.sh already runs at line 37 and pin_epel() arrived inside centos_mirror.sh, so main's hunk would have run it twice. - peertube 02_fix-application-schema.yml: take main's task name, its expect_rows: true (matching the first query in the same file) and its when: without default(); keep HEAD's changed_when: true, which the notify: compose-up depends on. - peertube check-application/defaults.sql: take main's information_schema query; HEAD's ::regclass cast raises instead of returning no rows when the table is absent. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
5b6666e70c
16 files changed
+192
-42
No files matched your search
@@ -17,6 +17,8 @@ def _make_repo_root(tmp: str, *, stamp_age_offset: float | None = None) -> Path:
|
||||
(root / "scripts" / "install").mkdir(parents=True)
|
||||
(root / "scripts" / "install" / "lint.sh").write_text("#\n", encoding="utf-8")
|
||||
(root / "pyproject.toml").write_text("[project]\n", encoding="utf-8")
|
||||
(root / cli._PINS).parent.mkdir(parents=True)
|
||||
(root / cli._PINS).write_text("---\n", encoding="utf-8")
|
||||
if stamp_age_offset is not None:
|
||||
stamp = root / cli._STAMP
|
||||
stamp.parent.mkdir(parents=True, exist_ok=True)
|
||||
@@ -86,6 +88,24 @@ class TestStampLogic(unittest.TestCase):
|
||||
inst.assert_called_once()
|
||||
self.assertTrue((root / cli._STAMP).exists())
|
||||
|
||||
def test_a_newer_release_pin_triggers_install(self) -> None:
|
||||
with TemporaryDirectory() as tmp:
|
||||
root = _make_repo_root(tmp, stamp_age_offset=60.0)
|
||||
pins = root / cli._PINS
|
||||
later = time.time() + 120.0
|
||||
os.utime(pins, (later, later))
|
||||
with (
|
||||
mock.patch.object(cli, "PROJECT_ROOT", root),
|
||||
mock.patch.object(cli.shutil, "which", return_value="/usr/bin/x"),
|
||||
mock.patch.object(
|
||||
cli.mermaid_cli, "browser_installed", return_value=True
|
||||
),
|
||||
mock.patch.object(cli, "_install_all") as inst,
|
||||
):
|
||||
rc = cli.main([])
|
||||
self.assertEqual(rc, 0)
|
||||
inst.assert_called_once()
|
||||
|
||||
def test_no_stamp_triggers_install_and_touches(self) -> None:
|
||||
with TemporaryDirectory() as tmp:
|
||||
root = _make_repo_root(tmp)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import unittest
|
||||
import unittest.mock as mock
|
||||
|
||||
from utils.install.lint import shfmt
|
||||
|
||||
_WANT = shfmt.resolve_release("shfmt")[1]
|
||||
|
||||
|
||||
def _ensure(*versions: str | None) -> mock.MagicMock:
|
||||
with (
|
||||
mock.patch.object(shfmt, "_installed_version", side_effect=list(versions)),
|
||||
mock.patch.object(shfmt, "_install_binary") as install,
|
||||
):
|
||||
shfmt.ensure()
|
||||
return install
|
||||
|
||||
|
||||
class TestEnsure(unittest.TestCase):
|
||||
def test_the_pinned_release_stays(self) -> None:
|
||||
_ensure(_WANT).assert_not_called()
|
||||
|
||||
def test_a_distribution_release_is_replaced(self) -> None:
|
||||
_ensure("3.8.0", _WANT).assert_called_once()
|
||||
|
||||
def test_a_missing_shfmt_is_installed(self) -> None:
|
||||
_ensure(None, _WANT).assert_called_once()
|
||||
|
||||
def test_a_shadowed_install_fails_loudly(self) -> None:
|
||||
with self.assertRaisesRegex(RuntimeError, "must precede"):
|
||||
_ensure("3.8.0", "3.8.0")
|
||||
|
||||
|
||||
class TestInstalledVersion(unittest.TestCase):
|
||||
def _version(self, **run: object) -> str | None:
|
||||
with mock.patch.object(shfmt.subprocess, "run", **run):
|
||||
return shfmt._installed_version()
|
||||
|
||||
def test_a_release_binary_drops_its_v(self) -> None:
|
||||
done = subprocess.CompletedProcess([], 0, stdout="v3.14.1\n", stderr="")
|
||||
self.assertEqual(self._version(return_value=done), "3.14.1")
|
||||
|
||||
def test_a_distribution_build_reads_as_is(self) -> None:
|
||||
done = subprocess.CompletedProcess([], 0, stdout="3.8.0\n", stderr="")
|
||||
self.assertEqual(self._version(return_value=done), "3.8.0")
|
||||
|
||||
def test_a_missing_binary_reads_as_none(self) -> None:
|
||||
self.assertIsNone(self._version(side_effect=FileNotFoundError("shfmt")))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user