From efa99902d0b8108734351ef25d717ffa943a5aa4 Mon Sep 17 00:00:00 2001 From: James Garner Date: Fri, 6 Sep 2024 14:39:10 +1200 Subject: [PATCH] Test reading hold state of snaps --- tests/unit/test_snap.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unit/test_snap.py b/tests/unit/test_snap.py index a8d5e34e..73256e68 100644 --- a/tests/unit/test_snap.py +++ b/tests/unit/test_snap.py @@ -1064,3 +1064,11 @@ def test_alias_raises_snap_error(self, mock_subprocess): universal_newlines=True, ) mock_subprocess.reset_mock() + + @patch("charms.operator_libs_linux.v2.snap.subprocess.check_output") + def test_held(self, mock_subprocess: MagicMock): + foo = snap.Snap("foo", snap.SnapState.Latest, "stable", "1", "classic") + mock_subprocess.return_value = {} + self.assertEqual(foo.held, False) + mock_subprocess.return_value = {"hold:": "key isn't checked"} + self.assertEqual(foo.held, True)