Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot test a container entrypoint easily #206

Open
dcermak opened this issue Apr 9, 2024 · 0 comments
Open

Cannot test a container entrypoint easily #206

dcermak opened this issue Apr 9, 2024 · 0 comments

Comments

@dcermak
Copy link
Owner

dcermak commented Apr 9, 2024

pytest_container can be used to test containers that run a persistent service, but it is rather inconvenient to test one-shot-style containers which only exist to run their CMD/ENTRYPOINT. For such a container image, you generally just want to invoke it as podman run --rm -it $img $params and act on the output/side effects.

At the moment, pytest_container provides no convenient way how to achieve this. One potential possible way is to use testinfra directly:

SOME_CTR = Container( ... )

def test_some_ctr(host, container_runtime):
    out = host.check_output(f"{container_runtime.runner_binary} run --rm -it {SOME_CTR.url}")
    # do smth with out

However, that quickly breaks down, when SOME_CTR is no longer a Container but a DerivedContainer as then we need to build the container beforehand. Executing this manually is laborious and inconvenient. It would be great to provide a helper or a new fixture here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant