Changeset View
Changeset View
Standalone View
Standalone View
src/settings/services/test/service_menu_deinstallation_test.rb
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
46 | #!/bin/sh | 46 | #!/bin/sh | ||
47 | touch #{@tmpdir}/deinstall.sh-run | 47 | touch #{@tmpdir}/deinstall.sh-run | ||
48 | DEINSTALL_SH | 48 | DEINSTALL_SH | ||
49 | File.write("#{archive_dir}/install.sh", <<-INSTALL_SH) | 49 | File.write("#{archive_dir}/install.sh", <<-INSTALL_SH) | ||
50 | #!/bin/sh | 50 | #!/bin/sh | ||
51 | touch #{@tmpdir}/install.sh-run | 51 | touch #{@tmpdir}/install.sh-run | ||
52 | INSTALL_SH | 52 | INSTALL_SH | ||
53 | 53 | | |||
54 | assert(covered_system('servicemenudeinstallation', archive_base)) | 54 | assert(system('servicemenuinstaller', 'uninstall', archive_base)) | ||
55 | 55 | | |||
56 | # deinstaller should be run | 56 | # deinstaller should be run | ||
57 | # installer should not be run | 57 | # installer should not be run | ||
58 | # archive_dir should have been correctly removed | 58 | # archive_dir should have been correctly removed | ||
59 | 59 | | |||
60 | assert_path_exist('deinstall.sh-run') | 60 | assert_path_exist('deinstall.sh-run') | ||
61 | assert_path_not_exist('install.sh-run') | 61 | assert_path_not_exist('install.sh-run') | ||
62 | assert_path_not_exist(archive_dir) | 62 | assert_path_not_exist(archive_dir) | ||
Show All 9 Lines | |||||
72 | #!/bin/sh | 72 | #!/bin/sh | ||
73 | if [ "$@" = "--uninstall" ]; then | 73 | if [ "$@" = "--uninstall" ]; then | ||
74 | touch #{@tmpdir}/install.sh-run | 74 | touch #{@tmpdir}/install.sh-run | ||
75 | exit 0 | 75 | exit 0 | ||
76 | fi | 76 | fi | ||
77 | exit 1 | 77 | exit 1 | ||
78 | INSTALL_SH | 78 | INSTALL_SH | ||
79 | 79 | | |||
80 | assert(covered_system('servicemenudeinstallation', archive_base)) | 80 | assert(system('servicemenuinstaller', 'uninstall', archive_base)) | ||
81 | 81 | | |||
82 | assert_path_not_exist('deinstall.sh-run') | 82 | assert_path_not_exist('deinstall.sh-run') | ||
83 | assert_path_exist('install.sh-run') | 83 | assert_path_exist('install.sh-run') | ||
84 | assert_path_not_exist(archive_dir) | 84 | assert_path_not_exist(archive_dir) | ||
85 | end | 85 | end | ||
86 | 86 | | |||
87 | # no scripts in sight | 87 | # no scripts in sight | ||
88 | def test_run_fail | 88 | def test_run_fail | ||
89 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | 89 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | ||
90 | archive_base = "#{service_dir}/foo.zip" | 90 | archive_base = "#{service_dir}/foo.zip" | ||
91 | archive_dir = "#{archive_base}-dir/foo-1.1/" | 91 | archive_dir = "#{archive_base}-dir/foo-1.1/" | ||
92 | FileUtils.mkpath(archive_dir) | 92 | FileUtils.mkpath(archive_dir) | ||
93 | 93 | | |||
94 | refute(covered_system('servicemenudeinstallation', archive_base)) | 94 | refute(system('servicemenuinstaller', 'uninstall', archive_base)) | ||
95 | 95 | | |||
96 | # I am unsure if deinstallation really should keep the files around. But | 96 | # I am unsure if deinstallation really should keep the files around. But | ||
97 | # that's how it behaved originally so it's supposedly intentional | 97 | # that's how it behaved originally so it's supposedly intentional | ||
98 | # - sitter, 2019 | 98 | # - sitter, 2019 | ||
99 | assert_path_exist(archive_dir) | 99 | assert_path_exist(archive_dir) | ||
100 | end | 100 | end | ||
101 | 101 | | |||
102 | # For desktop files things are a bit special. There is one in .local/share/servicemenu-download | 102 | # For desktop files things are a bit special. There is one in .local/share/servicemenu-download | ||
103 | # and another in the actual ServiceMenus dir. The latter gets removed by the | 103 | # and another in the actual ServiceMenus dir. The latter gets removed by the | ||
104 | # script, the former by KNS. | 104 | # script, the former by KNS. | ||
105 | def test_run_desktop | 105 | def test_run_desktop | ||
106 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | 106 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | ||
107 | downloaded_file = "#{service_dir}/foo.desktop" | 107 | downloaded_file = "#{service_dir}/foo.desktop" | ||
108 | FileUtils.mkpath(service_dir) | 108 | FileUtils.mkpath(service_dir) | ||
109 | FileUtils.touch(downloaded_file) | 109 | FileUtils.touch(downloaded_file) | ||
110 | 110 | | |||
111 | menu_dir = "#{ENV['XDG_DATA_HOME']}/kservices5/ServiceMenus/" | 111 | menu_dir = "#{ENV['XDG_DATA_HOME']}/kservices5/ServiceMenus/" | ||
112 | installed_file = "#{menu_dir}/foo.desktop" | 112 | installed_file = "#{menu_dir}/foo.desktop" | ||
113 | FileUtils.mkpath(menu_dir) | 113 | FileUtils.mkpath(menu_dir) | ||
114 | FileUtils.touch(installed_file) | 114 | FileUtils.touch(installed_file) | ||
115 | 115 | | |||
116 | assert(covered_system('servicemenudeinstallation', downloaded_file)) | 116 | assert(system('servicemenuinstaller', 'uninstall', downloaded_file)) | ||
117 | 117 | | |||
118 | assert_path_exist(downloaded_file) | 118 | assert_path_exist(downloaded_file) | ||
119 | assert_path_not_exist(installed_file) | 119 | assert_path_not_exist(installed_file) | ||
120 | end | 120 | end | ||
121 | end | 121 | end |