Skip to content

Commit

Permalink
fixed weirdness in tests...
Browse files Browse the repository at this point in the history
  • Loading branch information
0xricksanchez committed Oct 27, 2022
1 parent 7b29359 commit a183993
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/tests/test_kernel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_run_ssh_success() -> None:
cmd = "foobar --baz"
expected = f"cd {kb.docker_mnt}/{kb.kernel_root} && {cmd}"
kb._run_ssh(cmd)
assert kb.ssh_conn.run.assert_called_with(expected, echo=True, warn=False) is None
kb.ssh_conn.run.assert_called_with(expected, echo=True, warn=False)


def get_run_kbuilder(mode: str) -> KernelBuilder:
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_run_no_config_mode(a, b, c, d, e, f, g, h, j, k, lvname, m):
kb = get_run_kbuilder("noconfig")
kb.run()
expected = f"cd {kb.docker_mnt}/{kb.kernel_root}/arch/{kb.arch}/boot && ln -s bzImage Image"
assert kb.ssh_conn.run.assert_called_with(expected, echo=True) is None
kb.ssh_conn.run.assert_called_with(expected, echo=True)


@patch.object(KernelBuilder, "_add_modules", return_value=0)
Expand All @@ -261,7 +261,7 @@ def test_run_config_mode(a, b, c, d, e, f, g, h, j, k, lvname, m):
kb = get_run_kbuilder("config")
kb.run()
expected = f"cd {kb.docker_mnt}/{kb.kernel_root}/arch/{kb.arch}/boot && ln -s bzImage Image"
assert kb.ssh_conn.run.assert_called_with(expected, echo=True) is None
kb.ssh_conn.run.assert_called_with(expected, echo=True)


def test_wait_for_container() -> None:
Expand Down
34 changes: 14 additions & 20 deletions src/tests/test_rootfs_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ def test_run_container_full_cfg() -> None:
rfsb = RootFSBuilder(False, **{"kroot": "/tmp"})
rfsb.client = MagicMock()
rfsb.run_container()
assert (
rfsb.client.containers.run.assert_called_with(
None,
volumes={f"{Path.cwd() / 'io'}": {"bind": f"{rfsb.docker_mnt}", "mode": "rw"}},
detach=True,
privileged=True,
remove=True,
command=f"/bin/bash -c 'set -e; . /home/{rfsb.user}/rootfs.sh -n {rfsb.fs_name} -a x86_64 -d {rfsb.distribution} -p {rfsb.packages} -u {rfsb.user} -h {rfsb.hostname.strip()}'",
)
is None
rfsb.client.containers.run.assert_called_with(
None,
volumes={f"{Path.cwd() / 'io'}": {"bind": f"{rfsb.docker_mnt}", "mode": "rw"}},
detach=True,
privileged=True,
remove=True,
command=f"/bin/bash -c 'set -e; . /home/{rfsb.user}/rootfs.sh -n {rfsb.fs_name} -a x86_64 -d {rfsb.distribution} -p {rfsb.packages} -u {rfsb.user} -h {rfsb.hostname.strip()}'",
)


Expand All @@ -40,16 +37,13 @@ def test_run_container_no_hostname() -> None:
rfsb.hostname = ""
rfsb.client = MagicMock()
rfsb.run_container()
assert (
rfsb.client.containers.run.assert_called_with(
None,
volumes={f"{Path.cwd() / 'io'}": {"bind": f"{rfsb.docker_mnt}", "mode": "rw"}},
detach=True,
privileged=True,
remove=True,
command=f"/bin/bash -c 'set -e; . /home/{rfsb.user}/rootfs.sh -n {rfsb.fs_name} -a x86_64 -d {rfsb.distribution} -p {rfsb.packages} -u {rfsb.user}'",
)
is None
rfsb.client.containers.run.assert_called_with(
None,
volumes={f"{Path.cwd() / 'io'}": {"bind": f"{rfsb.docker_mnt}", "mode": "rw"}},
detach=True,
privileged=True,
remove=True,
command=f"/bin/bash -c 'set -e; . /home/{rfsb.user}/rootfs.sh -n {rfsb.fs_name} -a x86_64 -d {rfsb.distribution} -p {rfsb.packages} -u {rfsb.user}'",
)


Expand Down

0 comments on commit a183993

Please sign in to comment.