-
Notifications
You must be signed in to change notification settings - Fork 145
/
test_container_spec.py
70 lines (65 loc) · 2.25 KB
/
test_container_spec.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""Test container commands."""
import platform
from collections import defaultdict
import pytest
from meltano.core.container.container_spec import ContainerSpec
class TestContainerService:
@pytest.mark.parametrize(
"spec,payload",
[
(
ContainerSpec(
"lightdash/lightdash",
ports={"8080": "8000"},
),
{
"Cmd": None,
"Entrypoint": None,
"Image": "lightdash/lightdash",
"Env": [],
"ExposedPorts": {"8000": {}},
"HostConfig": {
"PortBindings": defaultdict(
list,
{
"8000": [
{
"HostPort": "8080",
"HostIP": "0.0.0.0", # noqa: S104v
}
],
},
),
"Binds": [],
},
},
),
(
ContainerSpec(
"lightdash/lightdash",
entrypoint="bash",
),
{
"Cmd": None,
"Entrypoint": "bash",
"Image": "lightdash/lightdash",
"Env": [],
"ExposedPorts": {},
"HostConfig": {
"PortBindings": defaultdict(list, {}),
"Binds": [],
},
},
),
],
ids=["port-mapping", "custom-entrypoint"],
)
@pytest.mark.asyncio
async def test_docker_config(self, spec: ContainerSpec, payload: dict):
"""Check Docker container config from container spec."""
if platform.system() == "Windows":
pytest.xfail(
"Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444"
)
config = spec.get_docker_config()
assert config == payload