test: add test_volume.py

This commit is contained in:
Xyphuz 2022-05-21 17:25:56 +08:00
parent de762d79b4
commit 9f9733bec9
2 changed files with 29 additions and 4 deletions

View file

@ -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

23
tests/test_volume.py Normal file
View file

@ -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