From 9f9733bec97485635ccd4961ab8b6ceb30a5e856 Mon Sep 17 00:00:00 2001 From: Xyphuz Date: Sat, 21 May 2022 17:25:56 +0800 Subject: [PATCH] test: add test_volume.py --- tests/test_extends.py | 10 ++++++---- tests/test_volume.py | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 tests/test_volume.py diff --git a/tests/test_extends.py b/tests/test_extends.py index ef8f755..0bc6a0c 100644 --- a/tests/test_extends.py +++ b/tests/test_extends.py @@ -5,18 +5,20 @@ from compose_viz.extends import Extends def test_extend_init_normal() -> None: try: - Extends(service_name="frontend", from_file="tests/in/000001.yaml") + e = Extends(service_name="frontend", from_file="tests/in/000001.yaml") - assert True + assert e.service_name == "frontend" + assert e.from_file == "tests/in/000001.yaml" except Exception as e: assert False, e def test_extend_init_without_from_file() -> None: try: - Extends(service_name="frontend") + e = Extends(service_name="frontend") - assert True + assert e.service_name == "frontend" + assert e.from_file is None except Exception as e: assert False, e diff --git a/tests/test_volume.py b/tests/test_volume.py new file mode 100644 index 0000000..a58b56e --- /dev/null +++ b/tests/test_volume.py @@ -0,0 +1,23 @@ +from compose_viz.volume import Volume, VolumeType + + +def test_extend_init_normal() -> None: + try: + v = Volume(source="./foo", target="./bar") + + assert v.source == "./foo" + assert v.target == "./bar" + assert v.type == VolumeType.volume + except Exception as e: + assert False, e + + +def test_extend_with_type() -> None: + try: + v = Volume(source="./foo", target="./bar", type=VolumeType.bind) + + assert v.source == "./foo" + assert v.target == "./bar" + assert v.type == VolumeType.bind + except Exception as e: + assert False, e