diff --git a/craft_application/services/fetch.py b/craft_application/services/fetch.py index 50f575aa..6c158279 100644 --- a/craft_application/services/fetch.py +++ b/craft_application/services/fetch.py @@ -90,7 +90,7 @@ def setup(self) -> None: "and still in development." ) - self._fetch_process = fetch.start_service() + self._fetch_process = fetch.start_service() def create_session(self, instance: craft_providers.Executor) -> dict[str, str]: """Create a new session. diff --git a/docs/reference/changelog.rst b/docs/reference/changelog.rst index aba83d90..623bf0a4 100644 --- a/docs/reference/changelog.rst +++ b/docs/reference/changelog.rst @@ -12,6 +12,8 @@ Application - ``AppCommand`` subclasses now will always receive a valid ``app_config`` dict. +- Fixes a bug where the fetch-service integration would try to spawn the + fetch-service process when running in managed mode. Commands ======== diff --git a/tests/unit/services/test_fetch.py b/tests/unit/services/test_fetch.py index c8883862..be887b17 100644 --- a/tests/unit/services/test_fetch.py +++ b/tests/unit/services/test_fetch.py @@ -186,3 +186,13 @@ def test_warning_experimental(mocker, fetch_service, run_on_host, emitter): warning_emitted = call("message", warning) in emitter.interactions assert warning_emitted == run_on_host + + +def test_setup_managed(mocker, fetch_service): + """The fetch-service process should only be checked/started when running on the host.""" + mock_start = mocker.patch.object(fetch, "start_service") + mocker.patch.object(ProviderService, "is_managed", return_value=True) + + fetch_service.setup() + + assert not mock_start.called