Skip to content

Commit

Permalink
refactor tests and add templated case
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamas Nyiri authored and Tamas Nyiri committed Apr 22, 2024
1 parent f22adee commit 4a44443
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions helm_tests/airflow_aux/test_pod_template_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,38 +901,28 @@ def test_airflow_kerberos_init_container(
assert initContainers[0]["name"] == "kerberos-init"
assert initContainers[0]["args"] == ["kerberos", "-o"]

def test_should_add_command(self):
@pytest.mark.parametrize(
"cmd, expected",
[
(["test", "command", "to", "run"], ["test", "command", "to", "run"]),
(["cmd", "{{ .Release.Name }}"], ["cmd", "release-name"]),
],
)
def test_should_add_command(self, cmd, expected):
docs = render_chart(
values={
"workers": {"command": ["test", "command", "to", "run"]},
"workers": {"command": cmd},
},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert ["test", "command", "to", "run"] == jmespath.search("spec.containers[0].command", docs[0])

def test_should_not_add_command_by_default(self):
docs = render_chart(
values={},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert None is jmespath.search("spec.containers[0].command", docs[0])

def test_should_not_add_command_if_value_none(self):
docs = render_chart(
values={"workers": {"command": None}},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert None is jmespath.search("spec.containers[0].command", docs[0])
assert expected == jmespath.search("spec.containers[0].command", docs[0])

def test_should_not_add_command_if_value_empty(self):
@pytest.mark.parametrize("values", [{"workers": {"command": None}}, {"workers": {"command": []}}, None])
def test_should_not_add_command(self, values):
docs = render_chart(
values={"workers": {"command": []}},
values=values,
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)
Expand Down

0 comments on commit 4a44443

Please sign in to comment.