-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for runtime service configuration key
https://docs.docker.com/compose/compose-file/05-services/#runtime Signed-off-by: Povilas Kanapickas <[email protected]>
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
import unittest | ||
from unittest import mock | ||
from podman_compose import container_to_args | ||
|
||
|
||
def create_compose_mock(): | ||
compose = mock.Mock() | ||
compose.project_name = "test_project_name" | ||
compose.dirname = "test_dirname" | ||
compose.container_names_by_service.get = mock.Mock(return_value=None) | ||
compose.prefer_volume_over_mount = False | ||
compose.default_net = None | ||
compose.networks = {} | ||
return compose | ||
|
||
|
||
def get_minimal_container(): | ||
return { | ||
"name": "project_name_service_name1", | ||
"service_name": "service_name", | ||
"image": "busybox", | ||
} | ||
|
||
|
||
class TestContainerToArgs(unittest.TestCase): | ||
async def test_minimal(self): | ||
c = create_compose_mock() | ||
|
||
cnt = get_minimal_container() | ||
|
||
args = await container_to_args(c, cnt) | ||
self.assertEqual( | ||
args, | ||
[ | ||
"--name=project_name_service_name1", | ||
"-d", | ||
"--net", | ||
"", | ||
"--network-alias", | ||
"service_name", | ||
"busybox", | ||
], | ||
) | ||
|
||
async def test_runtime(self): | ||
c = create_compose_mock() | ||
|
||
cnt = get_minimal_container() | ||
cnt["runtime"] = "runsc" | ||
|
||
args = await container_to_args(c, cnt) | ||
self.assertEqual( | ||
args, | ||
[ | ||
"--name=project_name_service_name1", | ||
"-d", | ||
"--net", | ||
"", | ||
"--network-alias", | ||
"service_name", | ||
"--runtime", | ||
"runsc", | ||
"busybox", | ||
], | ||
) |