refactor!: port shell scripts to Python package
Bash scripts were untestable and duplicated device/LUKS/mount logic; the lim/ package centralizes it behind one subprocess wrapper and a YAML image catalog (single point of truth). BREAKING CHANGE: scripts/*.sh removed. Use `lim --type <cmd>`; new types mount/umount/single-boot/raid1-boot/lock/unlock/import/export replace direct script calls. --extra is deprecated and ignored. - distributions.yml + lim/catalog.py hold the image catalog (PyYAML) - pytest suite: 102 tests with mocked subprocess (tests/unit) and a 250-line max file-length guard (tests/lint) - ruff strict (select ALL), GitHub Actions CI, Dependabot; Travis gone - Makefile: install (symlink ~/.local/bin/lim) and test targets - fixes over bash: SUDO_USER-aware chown, mmcblk/nvme partition paths, sha512 checksum support, whole-pipeline failure detection, blkid UUID fallback for pre-mounted images, conditional fstab seeding for PARTUUID/LABEL images, clean errors for missing binaries
This commit is contained in:
30
tests/unit/test_packages.py
Normal file
30
tests/unit/test_packages.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import pytest
|
||||
|
||||
from lim import config, packages
|
||||
from lim.errors import LimError
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def package_dir(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(config, "PACKAGE_PATH", tmp_path)
|
||||
return tmp_path
|
||||
|
||||
|
||||
def test_strips_comments_and_blank_lines(package_dir):
|
||||
(package_dir / "general.txt").write_text(
|
||||
"# header comment\nnano\ntree# inline comment\n\nhtop\n"
|
||||
)
|
||||
assert packages.get_packages("general") == ["nano", "tree", "htop"]
|
||||
|
||||
|
||||
def test_multiple_collections_are_concatenated(package_dir):
|
||||
(package_dir / "a.txt").write_text("one\n")
|
||||
subdir = package_dir / "server"
|
||||
subdir.mkdir()
|
||||
(subdir / "luks.txt").write_text("two\nthree\n")
|
||||
assert packages.get_packages("a", "server/luks") == ["one", "two", "three"]
|
||||
|
||||
|
||||
def test_missing_collection_raises(package_dir):
|
||||
with pytest.raises(LimError):
|
||||
packages.get_packages("does-not-exist")
|
||||
Reference in New Issue
Block a user