diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2026-09-10 14:45:27 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2026-09-10 14:45:27 -0400 |
| commit | 1e97e741ae89270801526234e3caaf5c7aacdca7 (patch) | |
| tree | 7846986332a774ba706291bf0afc6eb321395c36 /tests | |
| parent | d7115074060a3e9e682d511eae3c47a1c64042b8 (diff) | |
| download | decky-lsfg-vk-1e97e741ae89270801526234e3caaf5c7aacdca7.tar.gz decky-lsfg-vk-1e97e741ae89270801526234e3caaf5c7aacdca7.zip | |
fix: clean Flatpak state from uninstall API
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_plugin_flatpak_lifecycle.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/test_plugin_flatpak_lifecycle.py b/tests/test_plugin_flatpak_lifecycle.py index 25f09b6..613a807 100644 --- a/tests/test_plugin_flatpak_lifecycle.py +++ b/tests/test_plugin_flatpak_lifecycle.py @@ -57,6 +57,77 @@ class PluginFlatpakLifecycleTests(unittest.TestCase): plugin.installation_service.cleanup_on_uninstall.assert_called_once_with() plugin.flatpak_service.remove_plugin_owned_extensions.assert_called_once_with() + def test_uninstall_button_also_cleans_flatpak_support(self): + plugin = Plugin.__new__(Plugin) + plugin.installation_service = Mock() + plugin.installation_service.uninstall.return_value = { + "success": True, + "message": "lsfg-vk uninstalled successfully", + "error": None, + "removed_files": ["/home/deck/.local/lib/liblsfg-vk.so"], + } + plugin.flatpak_service = Mock() + plugin.flatpak_service.remove_plugin_owned_extensions.return_value = { + "success": True, + "message": "Plugin-owned Flatpak state removed", + "error": None, + "removed_branches": ["23.08", "24.08", "25.08"], + "preserved_branches": [], + "removed_filesystem_grants": ["/home/deck/.config/lsfg-vk"], + "preserved_filesystem_grants": [], + "ownership_uncertain": False, + } + + result = asyncio.run(plugin.uninstall_lsfg_vk()) + + plugin.installation_service.uninstall.assert_called_once_with() + plugin.flatpak_service.remove_plugin_owned_extensions.assert_called_once_with() + self.assertTrue(result["success"]) + self.assertEqual(result["flatpak_cleanup"]["removed_branches"], ["23.08", "24.08", "25.08"]) + + def test_uninstall_button_reports_flatpak_cleanup_failure(self): + plugin = Plugin.__new__(Plugin) + plugin.installation_service = Mock() + plugin.installation_service.uninstall.return_value = { + "success": True, + "message": "lsfg-vk uninstalled successfully", + "error": None, + "removed_files": [], + } + plugin.flatpak_service = Mock() + plugin.flatpak_service.remove_plugin_owned_extensions.return_value = { + "success": False, + "message": "", + "error": "Flatpak ownership metadata was not trusted", + "ownership_uncertain": True, + } + + result = asyncio.run(plugin.uninstall_lsfg_vk()) + + self.assertFalse(result["success"]) + self.assertIn("Flatpak ownership metadata was not trusted", result["error"]) + self.assertTrue(result["flatpak_cleanup"]["ownership_uncertain"]) + + def test_uninstall_button_fails_closed_if_flatpak_cleanup_raises(self): + plugin = Plugin.__new__(Plugin) + plugin.installation_service = Mock() + plugin.installation_service.uninstall.return_value = { + "success": True, + "message": "lsfg-vk uninstalled successfully", + "error": None, + "removed_files": [], + } + plugin.flatpak_service = Mock() + plugin.flatpak_service.remove_plugin_owned_extensions.side_effect = RuntimeError( + "ownership could not be established" + ) + + result = asyncio.run(plugin.uninstall_lsfg_vk()) + + self.assertFalse(result["success"]) + self.assertIn("ownership could not be established", result["error"]) + self.assertTrue(result["flatpak_cleanup"]["ownership_uncertain"]) + if __name__ == "__main__": unittest.main() |
