stages: add test for bootc.install-to-filesystem
This commit is contained in:
parent
226b50eba5
commit
af360b0d71
1 changed files with 50 additions and 0 deletions
50
stages/test/test_bootc_install_to_fs.py
Normal file
50
stages/test/test_bootc_install_to_fs.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os.path
|
||||
from contextlib import contextmanager
|
||||
from unittest.mock import patch
|
||||
|
||||
from osbuild.testutil.imports import import_module_from_path
|
||||
|
||||
|
||||
@patch("subprocess.run")
|
||||
def test_bootc_install_to_fs(mock_run, tmp_path):
|
||||
stage_path = os.path.join(os.path.dirname(__file__), "../org.osbuild.bootc.install-to-filesystem")
|
||||
stage = import_module_from_path("bootc_install_to_fs_stage", stage_path)
|
||||
|
||||
inputs = {
|
||||
"images": {
|
||||
"path": "/input/images/path",
|
||||
"data": {
|
||||
"archives": {
|
||||
"/input/images/path": {
|
||||
"format": "oci-archive",
|
||||
"name": "some-img-name",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
mounts = {
|
||||
"root": {
|
||||
"path": "/path/to/root",
|
||||
},
|
||||
}
|
||||
|
||||
@contextmanager
|
||||
def faked_tmp_dir():
|
||||
yield tmp_path
|
||||
with patch("tempfile.TemporaryDirectory", side_effect=faked_tmp_dir):
|
||||
stage.main(inputs, mounts)
|
||||
|
||||
assert len(mock_run.call_args_list) == 1
|
||||
args = mock_run.call_args_list[0].args
|
||||
assert len(args) == 1
|
||||
assert args[0] == [
|
||||
"bootc", "install", "to-filesystem",
|
||||
"--source-imgref", f"oci-archive:{tmp_path}/image",
|
||||
"--skip-fetch-check", "--generic-image",
|
||||
"/path/to/root",
|
||||
]
|
||||
kwargs = mock_run.call_args_list[0].kwargs
|
||||
assert kwargs["check"] is True
|
||||
Loading…
Add table
Add a link
Reference in a new issue