test: add integration test for Chroot.run()
This commit adds a test that is more "integration"-ish in style to make sure that the actual return code of a command is returned via chroot.
This commit is contained in:
parent
1b3e956334
commit
ad7c646712
1 changed files with 13 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
|||
import os
|
||||
from unittest.mock import call, patch
|
||||
|
||||
from osbuild.testutil import mock_command
|
||||
from osbuild.util.chroot import Chroot
|
||||
|
||||
|
||||
|
|
@ -41,3 +42,15 @@ def test_chroot_context(mocked_run, tmp_path):
|
|||
call(["umount", "--lazy", os.fspath(tmp_path / "dev")], check=False),
|
||||
call(["umount", "--lazy", os.fspath(tmp_path / "sys")], check=False),
|
||||
]
|
||||
|
||||
|
||||
def test_chroot_integration(tmp_path):
|
||||
# drop the first two arguments ("chroot", "target-dir") from our fake
|
||||
# chroot
|
||||
fake_chroot = r'exec "${@:2}"'
|
||||
with mock_command("mount", ""), mock_command("umount", ""), mock_command("chroot", fake_chroot):
|
||||
with Chroot(os.fspath(tmp_path)) as chroot:
|
||||
ret = chroot.run(["/bin/true"], check=True)
|
||||
assert ret.returncode == 0
|
||||
ret = chroot.run(["/bin/false"], check=False)
|
||||
assert ret.returncode == 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue