| 1 |
|
| 2 |
|
| 3 |
""" |
| 4 |
test_podman_compose_vol.py |
| 5 |
|
| 6 |
Tests the podman compose up and down commands used to create and remove services with volumes. |
| 7 |
""" |
| 8 |
|
| 9 |
|
| 10 |
import os |
| 11 |
import unittest |
| 12 |
|
| 13 |
from tests.integration.test_utils import RunSubprocessMixin |
| 14 |
from tests.integration.test_utils import podman_compose_path |
| 15 |
from tests.integration.test_utils import test_path |
| 16 |
|
| 17 |
|
| 18 |
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin): |
| 19 |
def test_down_with_vols(self) -> None: |
| 20 |
up_cmd = [ |
| 21 |
"coverage", |
| 22 |
"run", |
| 23 |
podman_compose_path(), |
| 24 |
"-f", |
| 25 |
os.path.join(test_path(), "vol", "docker-compose.yaml"), |
| 26 |
"up", |
| 27 |
"-d", |
| 28 |
] |
| 29 |
|
| 30 |
down_cmd = [ |
| 31 |
"coverage", |
| 32 |
"run", |
| 33 |
podman_compose_path(), |
| 34 |
"-f", |
| 35 |
os.path.join(test_path(), "vol", "docker-compose.yaml"), |
| 36 |
"down", |
| 37 |
"--volumes", |
| 38 |
] |
| 39 |
|
| 40 |
try: |
| 41 |
self.run_subprocess_assert_returncode(["podman", "volume", "create", "my-app-data"]) |
| 42 |
self.run_subprocess_assert_returncode([ |
| 43 |
"podman", |
| 44 |
"volume", |
| 45 |
"create", |
| 46 |
"actual-name-of-volume", |
| 47 |
]) |
| 48 |
|
| 49 |
self.run_subprocess_assert_returncode(up_cmd) |
| 50 |
self.run_subprocess(["podman", "inspect", "volume", ""]) |
| 51 |
|
| 52 |
finally: |
| 53 |
out, _, return_code = self.run_subprocess(down_cmd) |
| 54 |
self.run_subprocess(["podman", "volume", "rm", "my-app-data"]) |
| 55 |
self.run_subprocess(["podman", "volume", "rm", "actual-name-of-volume"]) |
| 56 |
self.assertEqual(return_code, 0) |