2022-05-16 18:57:14 +02:00
|
|
|
import os
|
|
|
|
|
2022-05-18 17:28:18 +02:00
|
|
|
import pytest
|
2022-05-07 18:42:14 +02:00
|
|
|
from typer.testing import CliRunner
|
|
|
|
|
2022-05-18 17:28:18 +02:00
|
|
|
from compose_viz import cli
|
2022-05-07 18:42:14 +02:00
|
|
|
|
|
|
|
runner = CliRunner()
|
|
|
|
|
2022-05-18 17:28:18 +02:00
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2022-05-24 10:02:47 +02:00
|
|
|
"test_file_path",
|
2022-05-18 17:28:18 +02:00
|
|
|
[
|
2022-05-24 10:02:47 +02:00
|
|
|
"builds/docker-compose",
|
|
|
|
"depends_on/docker-compose",
|
|
|
|
"extends/docker-compose",
|
|
|
|
"links/docker-compose",
|
|
|
|
"networks/docker-compose",
|
|
|
|
"ports/docker-compose",
|
|
|
|
"volumes/docker-compose",
|
2022-05-18 17:28:18 +02:00
|
|
|
],
|
|
|
|
)
|
2022-05-24 10:02:47 +02:00
|
|
|
def test_cli(test_file_path: str) -> None:
|
|
|
|
input_path = f"tests/ymls/{test_file_path}.yml"
|
|
|
|
output_path = "compose-viz-test.png"
|
2022-05-18 16:47:54 +02:00
|
|
|
result = runner.invoke(cli.app, ["-o", output_path, input_path])
|
2022-05-07 18:42:14 +02:00
|
|
|
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert f"Successfully parsed {input_path}\n" in result.stdout
|
2022-05-18 16:47:54 +02:00
|
|
|
assert os.path.exists(output_path)
|
|
|
|
|
|
|
|
os.remove(output_path)
|