diff --git a/lib/charms/operator_libs_linux/v2/snap.py b/lib/charms/operator_libs_linux/v2/snap.py index a706c166..7705feee 100644 --- a/lib/charms/operator_libs_linux/v2/snap.py +++ b/lib/charms/operator_libs_linux/v2/snap.py @@ -480,7 +480,7 @@ def stop(self, services: list[str] | None = None, disable: bool = False) -> None args = ["stop", "--disable"] if disable else ["stop"] self._snap_daemons(args, services) - def logs(self, services: list[str] | None = None, num_lines: int = 10) -> str: + def logs(self, services: list[str] | None = None, num_lines: int | Literal["all"] = 10) -> str: """Fetch a snap services' logs. Args: diff --git a/tests/unit/test_snap.py b/tests/unit/test_snap.py index a98c93f4..3b06373b 100644 --- a/tests/unit/test_snap.py +++ b/tests/unit/test_snap.py @@ -510,6 +510,14 @@ def test_can_run_snap_daemon_commands(self, mock_subprocess): capture_output=True, ) + foo.logs(num_lines='all') + mock_subprocess.assert_called_with( + ["snap", "logs", "-n=all", "foo"], + text=True, + check=True, + capture_output=True, + ) + foo.logs(services=["bar", "baz"], num_lines=None) mock_subprocess.assert_called_with( ["snap", "logs", "foo.bar", "foo.baz"],