|
4 | 4 | from os import path |
5 | 5 | from unittest import mock |
6 | 6 |
|
| 7 | +from parameterized import parameterized |
| 8 | + |
7 | 9 | from podman_compose import container_to_args |
8 | 10 |
|
9 | 11 |
|
@@ -428,3 +430,43 @@ async def test_gpu(self): |
428 | 430 | "nvidia-smi", |
429 | 431 | ], |
430 | 432 | ) |
| 433 | + |
| 434 | + @parameterized.expand([ |
| 435 | + (False, "z", ["--mount", "type=bind,source=./foo,destination=/mnt,z"]), |
| 436 | + (False, "Z", ["--mount", "type=bind,source=./foo,destination=/mnt,Z"]), |
| 437 | + (True, "z", ["-v", "./foo:/mnt:z"]), |
| 438 | + (True, "Z", ["-v", "./foo:/mnt:Z"]), |
| 439 | + ]) |
| 440 | + async def test_selinux_volume(self, prefer_volume, selinux_type, expected_additional_args): |
| 441 | + c = create_compose_mock() |
| 442 | + c.prefer_volume_over_mount = prefer_volume |
| 443 | + |
| 444 | + cnt = get_minimal_container() |
| 445 | + |
| 446 | + # This is supposed to happen during `_parse_compose_file` |
| 447 | + # but that is probably getting skipped during testing |
| 448 | + cnt["_service"] = cnt["service_name"] |
| 449 | + |
| 450 | + cnt["volumes"] = [ |
| 451 | + { |
| 452 | + "type": "bind", |
| 453 | + "source": "./foo", |
| 454 | + "target": "/mnt", |
| 455 | + "bind": { |
| 456 | + "selinux": selinux_type, |
| 457 | + }, |
| 458 | + } |
| 459 | + ] |
| 460 | + |
| 461 | + args = await container_to_args(c, cnt) |
| 462 | + self.assertEqual( |
| 463 | + args, |
| 464 | + [ |
| 465 | + "--name=project_name_service_name1", |
| 466 | + "-d", |
| 467 | + *expected_additional_args, |
| 468 | + "--network=bridge", |
| 469 | + "--network-alias=service_name", |
| 470 | + "busybox", |
| 471 | + ], |
| 472 | + ) |
0 commit comments