2021-10-25 10:08:04 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
2021-10-28 14:48:54 +00:00
|
|
|
from ruamel.yaml import CommentedMap
|
|
|
|
|
2021-10-25 10:08:04 +00:00
|
|
|
from kiwi_scp.instance import Service
|
|
|
|
|
|
|
|
|
2021-10-26 14:11:28 +00:00
|
|
|
class TestDefault:
|
2021-10-28 14:48:54 +00:00
|
|
|
def test_empty(self):
|
|
|
|
s = Service(
|
2021-10-26 14:11:28 +00:00
|
|
|
name="s",
|
2021-11-03 16:35:36 +00:00
|
|
|
content=CommentedMap(),
|
2021-10-26 14:11:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert s.name == "s"
|
2021-10-28 14:48:54 +00:00
|
|
|
assert list(s.configs) == []
|
2021-10-26 14:11:28 +00:00
|
|
|
|
|
|
|
def test_no_configs(self):
|
2021-10-28 14:48:54 +00:00
|
|
|
s = Service(
|
2021-10-26 14:11:28 +00:00
|
|
|
name="s",
|
2021-11-03 16:35:36 +00:00
|
|
|
content=CommentedMap({
|
2021-10-26 14:11:28 +00:00
|
|
|
"image": "repo/image:tag",
|
2021-10-28 14:48:54 +00:00
|
|
|
}),
|
2021-10-26 14:11:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert s.name == "s"
|
2021-10-28 14:48:54 +00:00
|
|
|
assert list(s.configs) == []
|
2021-10-26 14:11:28 +00:00
|
|
|
|
|
|
|
def test_no_configs_in_volumes(self):
|
2021-10-28 14:48:54 +00:00
|
|
|
s = Service(
|
2021-10-26 14:11:28 +00:00
|
|
|
name="s",
|
2021-11-03 16:35:36 +00:00
|
|
|
content=CommentedMap({
|
2021-10-26 14:11:28 +00:00
|
|
|
"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",
|
|
|
|
]
|
2021-10-28 14:48:54 +00:00
|
|
|
}),
|
2021-10-26 14:11:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert s.name == "s"
|
2021-10-28 14:48:54 +00:00
|
|
|
assert list(s.configs) == []
|
2021-10-26 14:11:28 +00:00
|
|
|
|
|
|
|
def test_with_configs(self):
|
2021-10-28 14:48:54 +00:00
|
|
|
s = Service(
|
2021-10-26 14:11:28 +00:00
|
|
|
name="s",
|
2021-11-03 16:35:36 +00:00
|
|
|
content=CommentedMap({
|
2021-10-26 14:11:28 +00:00
|
|
|
"image": "repo/image:tag",
|
|
|
|
"volumes": [
|
|
|
|
"${CONFDIR}/some/config:/path/to/some/config",
|
|
|
|
"$CONFDIR/other/config:/path/to/other/config",
|
|
|
|
]
|
2021-10-28 14:48:54 +00:00
|
|
|
}),
|
2021-10-26 14:11:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert s.name == "s"
|
2021-10-28 14:48:54 +00:00
|
|
|
assert len(list(s.configs)) == 2
|
|
|
|
assert list(s.configs) == [
|
2021-10-26 14:11:28 +00:00
|
|
|
Path("some/config"),
|
|
|
|
Path("other/config"),
|
|
|
|
]
|