from pathlib import Path

from metis.pkg.inject import Injector, FileSpec


def test_inject_write(tmp_path):
    boot = tmp_path / "boot"
    root = tmp_path / "root"
    inj = Injector(BootPath=str(boot), RootPath=str(root))
    files = [
        FileSpec(Path="config.txt", Content=b"bootcfg", Mode=0o644, RootFS=False),
        FileSpec(Path="etc/hostname", Content=b"node", Mode=0o644, RootFS=True),
    ]
    inj.Write(files)
    assert (boot / "config.txt").read_bytes() == b"bootcfg"
    assert (root / "etc/hostname").read_bytes() == b"node"
