Skip to content

Commit e5a2325

Browse files
committed
add tests
Signed-off-by: mgorsk1 <[email protected]>
1 parent 918f120 commit e5a2325

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

core/tests/test_core.py

+31
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from testcontainers.core.container import DockerContainer
1010
from testcontainers.core.image import DockerImage
11+
from testcontainers.core.transferable import Transferable
1112
from testcontainers.core.waiting_utils import wait_for_logs
1213

1314

@@ -92,3 +93,33 @@ def test_docker_image_with_custom_dockerfile_path(dockerfile_path: Optional[Path
9293
with DockerContainer(str(image)) as container:
9394
assert container._container.image.short_id.endswith(image_short_id), "Image ID mismatch"
9495
assert container.get_logs() == (("Hello world!\n").encode(), b""), "Container logs mismatch"
96+
97+
98+
def test_docker_start_with_copy_file_to_container_from_binary_transferable(tmp_path: Path) -> None:
99+
container = DockerContainer("nginx")
100+
data = "test_docker_start_with_copy_file_to_container_from_binary_transferable"
101+
102+
input_data = data.encode("utf-8")
103+
output_file = Path("/tmp/test_docker_start_with_copy_file_to_container_from_binary_transferable.txt")
104+
105+
container.with_copy_file_to_container(Transferable(input_data, output_file)).start()
106+
107+
_, stdout = container.exec(f"cat {output_file}")
108+
assert stdout.decode() == data
109+
110+
111+
def test_docker_start_with_copy_file_to_container_from_file_transferable(tmp_path: Path) -> None:
112+
container = DockerContainer("nginx")
113+
data = "test_docker_start_with_copy_file_to_container_from_file_transferable"
114+
115+
with tempfile.NamedTemporaryFile(delete=True) as f:
116+
f.write(data.encode("utf-8"))
117+
f.seek(0)
118+
119+
input_file = Path(f.name)
120+
output_file = Path("/tmp/test_docker_start_with_copy_file_to_container_from_file_transferable.txt")
121+
122+
container.with_copy_file_to_container(Transferable(input_file, output_file)).start()
123+
124+
_, stdout = container.exec(f"cat {output_file}")
125+
assert stdout.decode() == data

0 commit comments

Comments
 (0)