-
-
Notifications
You must be signed in to change notification settings - Fork 607
/
run_image_integration_test.py
40 lines (32 loc) · 1.09 KB
/
run_image_integration_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import annotations
from textwrap import dedent
from pants.testutil.pants_integration_test import PantsResult, run_pants, setup_tmpdir
def run_pants_with_sources(sources: dict[str, str], *args: str) -> PantsResult:
with setup_tmpdir(sources) as tmpdir:
return run_pants(
[
"--backend-packages=pants.backend.docker",
"--pants-ignore=__pycache__",
]
+ [arg.format(tmpdir=tmpdir) for arg in args]
)
def test_docker_run() -> None:
sources = {
"BUILD": "docker_image(name='run-image')",
"Dockerfile": dedent(
"""\
FROM alpine
CMD echo "Hello from Docker image"
"""
),
}
result = run_pants_with_sources(
sources,
"run",
"{tmpdir}:run-image",
)
print("pants stderr\n", result.stderr)
assert "Hello from Docker image\n" == result.stdout
result.assert_success()