mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-24 21:52:59 +00:00
66 lines
1.7 KiB
Python
66 lines
1.7 KiB
Python
from pathlib import Path
|
|
|
|
from ruamel.yaml import CommentedMap
|
|
|
|
from kiwi_scp.service import Service
|
|
|
|
|
|
class TestDefault:
|
|
def test_empty(self):
|
|
s = Service(
|
|
name="s",
|
|
content=CommentedMap(),
|
|
parent=None,
|
|
)
|
|
|
|
assert s.name == "s"
|
|
assert list(s.configs) == []
|
|
|
|
def test_no_configs(self):
|
|
s = Service(
|
|
name="s",
|
|
content=CommentedMap({
|
|
"image": "repo/image:tag",
|
|
}),
|
|
parent=None,
|
|
)
|
|
|
|
assert s.name == "s"
|
|
assert list(s.configs) == []
|
|
|
|
def test_no_configs_in_volumes(self):
|
|
s = Service(
|
|
name="s",
|
|
content=CommentedMap({
|
|
"image": "repo/image:tag",
|
|
"volumes": [
|
|
"docker_volume/third/dir:/path/to/third/mountpoint",
|
|
"${TARGETDIR}/some/dir:/path/to/some/mountpoint",
|
|
"$TARGETDIR/other/dir:/path/to/other/mountpoint",
|
|
]
|
|
}),
|
|
parent=None,
|
|
)
|
|
|
|
assert s.name == "s"
|
|
assert list(s.configs) == []
|
|
|
|
def test_with_configs(self):
|
|
s = Service(
|
|
name="s",
|
|
content=CommentedMap({
|
|
"image": "repo/image:tag",
|
|
"volumes": [
|
|
"${CONFDIR}/some/config:/path/to/some/config",
|
|
"$CONFDIR/other/config:/path/to/other/config",
|
|
]
|
|
}),
|
|
parent=None,
|
|
)
|
|
|
|
assert s.name == "s"
|
|
assert len(list(s.configs)) == 2
|
|
assert list(s.configs) == [
|
|
Path("some/config"),
|
|
Path("other/config"),
|
|
]
|