Skip to content

Commit 3a012a7

Browse files
committed
- Test added.
issue #93
1 parent 8732687 commit 3a012a7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/test_cli/test_templating/test_processors.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,44 @@ def test_answers_with_previous_answers(self):
118118
answers = yaml.safe_load(file)
119119
self.assertEqual(expected_answers, answers)
120120

121+
def test_answers_do_not_override_template_registry_and_version(self):
122+
expected_answers = {
123+
"foo": "foo_answer",
124+
"template_registry": f"{TEMPLATE_URL}/{TEMPLATE_VERSION}",
125+
"template_version": TEMPLATE_VERSION,
126+
}
127+
with TemporaryDirectory() as tmp_dir_name:
128+
project_destination = Path(tmp_dir_name)
129+
(project_destination / ".minos-project.yaml").touch()
130+
minos_answers_file = project_destination / ".minos-answers.yml"
131+
minos_answers_file.touch()
132+
133+
with minos_answers_file.open("w") as file:
134+
answers_with_wrong_version = {
135+
"foo": "foo_answer",
136+
"template_registry": f"{TEMPLATE_URL}/wrong_version",
137+
"template_version": "wrong_version",
138+
}
139+
yaml.dump(
140+
answers_with_wrong_version,
141+
file,
142+
)
143+
144+
microservice_destination = project_destination / "microservices" / "foo"
145+
microservice_destination.mkdir(parents=True)
146+
147+
processor = TemplateProcessor.from_fetcher(
148+
self.fetcher,
149+
microservice_destination,
150+
)
151+
152+
with patch("minos.cli.Form.ask", return_value=expected_answers) as mock:
153+
self.assertEqual(expected_answers, processor.answers)
154+
155+
self.assertEqual(
156+
[call(context=processor.context | expected_answers, env=processor.env)], mock.call_args_list,
157+
)
158+
121159
def test_answers_without_previous_answers(self):
122160
with TemporaryDirectory() as tmp_dir_name:
123161
destination = Path(tmp_dir_name)

0 commit comments

Comments
 (0)