2022-05-24 11:06:31 +02:00
|
|
|
from compose_viz.volume import Volume, VolumeType
|
2022-05-21 11:25:56 +02:00
|
|
|
|
|
|
|
|
2022-05-21 17:00:20 +02:00
|
|
|
def test_volume_init_normal() -> None:
|
2022-05-21 11:25:56 +02:00
|
|
|
try:
|
|
|
|
v = Volume(source="./foo", target="./bar")
|
|
|
|
|
|
|
|
assert v.source == "./foo"
|
|
|
|
assert v.target == "./bar"
|
|
|
|
assert v.type == VolumeType.volume
|
2022-05-24 11:06:31 +02:00
|
|
|
assert v.access_mode == "rw"
|
2022-05-21 11:25:56 +02:00
|
|
|
except Exception as e:
|
|
|
|
assert False, e
|
|
|
|
|
|
|
|
|
2022-05-21 17:00:20 +02:00
|
|
|
def test_volume_with_type() -> None:
|
2022-05-21 11:25:56 +02:00
|
|
|
try:
|
|
|
|
v = Volume(source="./foo", target="./bar", type=VolumeType.bind)
|
|
|
|
|
|
|
|
assert v.source == "./foo"
|
|
|
|
assert v.target == "./bar"
|
|
|
|
assert v.type == VolumeType.bind
|
2022-05-24 11:06:31 +02:00
|
|
|
assert v.access_mode == "rw"
|
2022-05-22 06:34:18 +02:00
|
|
|
except Exception as e:
|
|
|
|
assert False, e
|
|
|
|
|
|
|
|
|
|
|
|
def test_volume_with_access_mode() -> None:
|
|
|
|
try:
|
2022-05-24 11:06:31 +02:00
|
|
|
v = Volume(source="./foo", target="./bar", access_mode="ro,z")
|
2022-05-22 06:34:18 +02:00
|
|
|
|
|
|
|
assert v.source == "./foo"
|
|
|
|
assert v.target == "./bar"
|
|
|
|
assert v.type == VolumeType.volume
|
2022-05-24 11:06:31 +02:00
|
|
|
assert v.access_mode == "ro,z"
|
2022-05-21 11:25:56 +02:00
|
|
|
except Exception as e:
|
|
|
|
assert False, e
|