Public Access
DEVX-163: fix: check stdout for HTTP 500 in _run_push (docker sends to stdout)
This commit was merged in pull request #307.
This commit is contained in:
@@ -288,7 +288,7 @@ class TestPushImage:
|
||||
"""HTTP 500 from registry race condition — retry succeeds."""
|
||||
spec = ImageSpec(name="ci-base", dockerfile="Dockerfile", tags=["latest"])
|
||||
results = [
|
||||
MagicMock(returncode=1, stderr="received unexpected HTTP status: 500 Internal Server Error", stdout=""),
|
||||
MagicMock(returncode=1, stderr="", stdout="received unexpected HTTP status: 500 Internal Server Error"),
|
||||
MagicMock(returncode=0, stderr="", stdout=""),
|
||||
]
|
||||
with (
|
||||
@@ -303,7 +303,7 @@ class TestPushImage:
|
||||
"""HTTP 500 retries exhausted — push fails, no delete attempted."""
|
||||
spec = ImageSpec(name="ci-base", dockerfile="Dockerfile", tags=["latest"])
|
||||
mock_result = MagicMock(
|
||||
returncode=1, stderr="received unexpected HTTP status: 500 Internal Server Error", stdout=""
|
||||
returncode=1, stderr="", stdout="received unexpected HTTP status: 500 Internal Server Error"
|
||||
)
|
||||
with (
|
||||
patch("devx.tools.build_image.subprocess.run", return_value=mock_result),
|
||||
@@ -313,7 +313,7 @@ class TestPushImage:
|
||||
assert push_image(spec, "git.example.com", username="user", token="tok") is False
|
||||
mock_del.assert_not_called()
|
||||
|
||||
def test_run_push_raises_on_500(self) -> None:
|
||||
def test_run_push_raises_on_500_stderr(self) -> None:
|
||||
"""_run_push raises PushHTTP500Error when stderr contains 500."""
|
||||
from devx.tools.build_image import _run_push
|
||||
|
||||
@@ -322,6 +322,17 @@ class TestPushImage:
|
||||
with pytest.raises(PushHTTP500Error, match="HTTP 500"):
|
||||
_run_push(["docker", "push", "img:latest"])
|
||||
|
||||
def test_run_push_raises_on_500_stdout(self) -> None:
|
||||
"""_run_push raises PushHTTP500Error when stdout contains 500 (docker sends to stdout)."""
|
||||
from devx.tools.build_image import _run_push
|
||||
|
||||
mock_result = MagicMock(
|
||||
returncode=1, stderr="", stdout="received unexpected HTTP status: 500 Internal Server Error"
|
||||
)
|
||||
with patch("devx.tools.build_image.subprocess.run", return_value=mock_result):
|
||||
with pytest.raises(PushHTTP500Error, match="500"):
|
||||
_run_push(["docker", "push", "img:latest"])
|
||||
|
||||
def test_run_push_no_raise_on_non_500(self) -> None:
|
||||
"""_run_push returns result when stderr has no 500."""
|
||||
from devx.tools.build_image import _run_push
|
||||
|
||||
Reference in New Issue
Block a user