Changeset View
Changeset View
Standalone View
Standalone View
src/settings/services/test/service_menu_deinstallation_test.rb
Show All 14 Lines | |||||
15 | # You should have received a copy of the GNU General Public License | 15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this program; if not, write to the | 16 | # along with this program; if not, write to the | ||
17 | # Free Software Foundation, Inc., | 17 | # Free Software Foundation, Inc., | ||
18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | 19 | | |||
20 | require_relative 'test_helper' | 20 | require_relative 'test_helper' | ||
21 | 21 | | |||
22 | require 'tmpdir' | 22 | require 'tmpdir' | ||
23 | 23 | | |||
sitter: sort alphabetically please | |||||
24 | class ServiceMenuDeinstallationTest < Test::Unit::TestCase | 24 | class ServiceMenuDeinstallationTest < Test::Unit::TestCase | ||
25 | def setup | 25 | def setup | ||
26 | @tmpdir = Dir.mktmpdir("dolphintest-#{self.class.to_s.tr(':', '_')}") | 26 | @tmpdir = Dir.mktmpdir("dolphintest-#{self.class.to_s.tr(':', '_')}") | ||
27 | @pwdir = Dir.pwd | 27 | @pwdir = Dir.pwd | ||
28 | Dir.chdir(@tmpdir) | 28 | Dir.chdir(@tmpdir) | ||
29 | 29 | | |||
30 | ENV['XDG_DATA_HOME'] = File.join(@tmpdir, 'data') | 30 | ENV['XDG_DATA_HOME'] = File.join(@tmpdir, 'data') | ||
31 | end | 31 | end | ||
32 | 32 | | |||
33 | def teardown | 33 | def teardown | ||
34 | Dir.chdir(@pwdir) | 34 | Dir.chdir(@pwdir) | ||
35 | FileUtils.rm_rf(@tmpdir) | 35 | FileUtils.rm_rf(@tmpdir) | ||
36 | 36 | | |||
37 | ENV.delete('XDG_DATA_HOME') | 37 | ENV.delete('XDG_DATA_HOME') | ||
38 | end | 38 | end | ||
39 | 39 | | |||
40 | def test_run_deinstall | 40 | def test_run_deinstall | ||
41 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | 41 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | ||
42 | archive_base = "#{service_dir}/foo.zip" | 42 | archive_base = "#{service_dir}/foo.zip" | ||
43 | archive_dir = "#{archive_base}-dir/foo-1.1/" | 43 | archive_dir = "#{archive_base}-dir/foo-1.1/" | ||
44 | FileUtils.mkpath(archive_dir) | 44 | FileUtils.mkpath(archive_dir) | ||
45 | File.write("#{archive_dir}/deinstall.sh", <<-DEINSTALL_SH) | 45 | File.write("#{archive_dir}/deinstall.sh", <<-DEINSTALL_SH) | ||
46 | #!/bin/sh | 46 | #!/bin/sh | ||
47 | set -e | ||||
48 | cat deinstall.sh | ||||
47 | touch #{@tmpdir}/deinstall.sh-run | 49 | touch #{@tmpdir}/deinstall.sh-run | ||
48 | DEINSTALL_SH | 50 | DEINSTALL_SH | ||
49 | File.write("#{archive_dir}/install.sh", <<-INSTALL_SH) | 51 | File.write("#{archive_dir}/install.sh", <<-INSTALL_SH) | ||
50 | #!/bin/sh | 52 | #!/bin/sh | ||
53 | set -e | ||||
54 | cat install.sh | ||||
51 | touch #{@tmpdir}/install.sh-run | 55 | touch #{@tmpdir}/install.sh-run | ||
52 | INSTALL_SH | 56 | INSTALL_SH | ||
53 | 57 | | |||
54 | assert(system('servicemenuinstaller', 'uninstall', archive_base)) | 58 | assert(system('servicemenuinstaller', 'uninstall', archive_base)) | ||
55 | 59 | | |||
56 | # deinstaller should be run | 60 | # deinstaller should be run | ||
57 | # installer should not be run | 61 | # installer should not be run | ||
58 | # archive_dir should have been correctly removed | 62 | # archive_dir should have been correctly removed | ||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |
sort alphabetically please