fix(docker): surface enumeration failures
This commit is contained in:
@@ -69,6 +69,19 @@ class TestComposeProjectListing(unittest.TestCase):
|
||||
self.assertEqual([], list_active_slugs(warn_on_error=False))
|
||||
warn.assert_not_called()
|
||||
|
||||
def test_compose_ls_error_can_be_raised_for_enumeration(self):
|
||||
with mock.patch(
|
||||
"bot_bottle.backend.docker.compose.subprocess.run",
|
||||
return_value=subprocess.CompletedProcess(
|
||||
args=["docker"], returncode=1, stdout="", stderr="no daemon",
|
||||
),
|
||||
):
|
||||
with self.assertRaisesRegex(RuntimeError, "no daemon"):
|
||||
list_active_slugs(
|
||||
warn_on_error=False,
|
||||
raise_on_error=True,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -19,9 +19,11 @@ of issue #77 — the dashboard now delegates to this layer.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from tests.unit import use_bottle_root
|
||||
from bot_bottle import bottle_state
|
||||
@@ -72,6 +74,18 @@ class TestParseServicesByProject(unittest.TestCase):
|
||||
self.assertEqual({"bot-bottle-dev-abc": {"egress"}}, out)
|
||||
|
||||
|
||||
class TestQueryServicesByProject(unittest.TestCase):
|
||||
def test_docker_ps_failure_is_not_an_empty_result(self):
|
||||
with patch(
|
||||
"bot_bottle.backend.docker.enumerate.subprocess.run",
|
||||
return_value=subprocess.CompletedProcess(
|
||||
args=["docker"], returncode=1, stdout="", stderr="daemon down",
|
||||
),
|
||||
):
|
||||
with self.assertRaisesRegex(RuntimeError, "daemon down"):
|
||||
_enumerate._query_services_by_project()
|
||||
|
||||
|
||||
class _FakeHomeMixin:
|
||||
def _setup_fake_home(self) -> None:
|
||||
self._tmp = tempfile.TemporaryDirectory(prefix="enum-active.")
|
||||
|
||||
Reference in New Issue
Block a user