From 0d24c41afb14a71fd3a04908e53b7834086f4038 Mon Sep 17 00:00:00 2001 From: Monika Kairaityte Date: Tue, 9 Jul 2024 18:50:44 +0200 Subject: [PATCH] tests/integration: Automate 'env-tests' manual test Signed-off-by: Monika Kairaityte --- tests/integration/env-tests/README.md | 5 --- tests/integration/test_podman_compose_env.py | 38 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) delete mode 100644 tests/integration/env-tests/README.md create mode 100644 tests/integration/test_podman_compose_env.py diff --git a/tests/integration/env-tests/README.md b/tests/integration/env-tests/README.md deleted file mode 100644 index b1c96cf..0000000 --- a/tests/integration/env-tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -running the following command should give myval2 - -``` -podman_compose run -l monkey -e ZZVAR1=myval2 env-test -``` diff --git a/tests/integration/test_podman_compose_env.py b/tests/integration/test_podman_compose_env.py new file mode 100644 index 0000000..2eb6d30 --- /dev/null +++ b/tests/integration/test_podman_compose_env.py @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: GPL-2.0 + +import os +import unittest + +from tests.integration.test_podman_compose import podman_compose_path +from tests.integration.test_podman_compose import test_path +from tests.integration.test_utils import RunSubprocessMixin + + +def compose_yaml_path(): + return os.path.join(os.path.join(test_path(), "env-tests"), "container-compose.yml") + + +class TestComposeEnv(unittest.TestCase, RunSubprocessMixin): + """Test that inline environment variable overrides environment variable from compose file.""" + + def test_env(self): + try: + output, _ = self.run_subprocess_assert_returncode([ + podman_compose_path(), + "-f", + compose_yaml_path(), + "run", + "-l", + "monkey", + "-e", + "ZZVAR1=myval2", + "env-test", + ]) + self.assertIn("ZZVAR1='myval2'", str(output)) + finally: + self.run_subprocess_assert_returncode([ + podman_compose_path(), + "-f", + compose_yaml_path(), + "down", + ])