Skip to content

Commit 212653d

Browse files
committed
add test
1 parent 5c8e9eb commit 212653d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/unit/ctl/test_repository_app.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"""Integration tests for infrahubctl commands."""
22

33
import sys
4+
import tempfile
5+
from pathlib import Path
46
from unittest import mock
57

68
import pytest
9+
import yaml
710
from typer.testing import CliRunner
811

912
from infrahub_sdk.client import InfrahubClient
@@ -288,3 +291,31 @@ def test_repo_list(self, mock_repositories_list) -> None:
288291
result = runner.invoke(app, ["repository", "list", "--branch", "main"])
289292
assert result.exit_code == 0
290293
assert strip_color(result.stdout) == read_fixture("output.txt", "integration/test_infrahubctl/repository_list")
294+
295+
def test_repo_init(self) -> None:
296+
with tempfile.TemporaryDirectory() as temp_dst, tempfile.NamedTemporaryFile(
297+
mode="w", suffix=".yml", delete=False, encoding="utf-8"
298+
) as temp_yaml:
299+
dst = Path(temp_dst)
300+
yaml_path = Path(temp_yaml.name)
301+
302+
answers = {
303+
"generators": True,
304+
"menus": True,
305+
"project_name": "test",
306+
"queries": True,
307+
"scripts": True,
308+
"tests": True,
309+
"transforms": True,
310+
}
311+
312+
yaml.safe_dump(answers, temp_yaml)
313+
temp_yaml.close()
314+
runner.invoke(app, ["repository", "init", str(dst), "--data", str(yaml_path)])
315+
316+
coppied_answers = yaml.safe_load((dst / ".copier-answers.yml").read_text())
317+
coppied_answers.pop("_src_path")
318+
319+
assert coppied_answers == answers
320+
assert (dst / "generators").is_dir()
321+
assert (dst / "pyproject.toml").is_file()

0 commit comments

Comments
 (0)