Skip to content

Commit

Permalink
Test podman custom executable
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Oct 12, 2023
1 parent c4440b3 commit 903d01d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/unit/test_podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,36 @@ def test_run_detach_stream_exited():
c.remove()
with pytest.raises(PodmanCommandError):
c.reload()


def test_custom_executable(tmp_path):
# Use a wrapper script to log commands
log = tmp_path.joinpath("log")
exe = tmp_path.joinpath("custom_exe.sh")
with exe.open("w") as f:
f.write("#!/bin/sh\n")
f.write(f"echo $@ >> {log}\n")
f.write("exec podman $@\n")
exe.chmod(0o755)

client = PodmanEngine(parent=None)
client.podman_executable = str(exe)
c = client.run(BUSYBOX, command=["id", "-un"])
assert isinstance(c, PodmanContainer)
assert c._podman_executable == str(exe)
cid = c.id

# If image was pulled the progress logs will also be present
out = c.logs().splitlines()
assert out[-1].strip() == b"root", out

c.remove()

with log.open() as f:
lines = f.read().splitlines()
assert lines == [
f"run --detach --log-level=debug {BUSYBOX} id -un",
f"inspect --type container --format json {cid}",
f"logs {cid}",
f"rm {cid}",
]

0 comments on commit 903d01d

Please sign in to comment.