Changeset View
Changeset View
Standalone View
Standalone View
src/settings/services/test/service_menu_installation_test.rb
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
49 | touch #{@tmpdir}/install-it.sh-run | 49 | touch #{@tmpdir}/install-it.sh-run | ||
50 | INSTALL_IT_SH | 50 | INSTALL_IT_SH | ||
51 | File.write("#{archive_dir}/install.sh", <<-INSTALL_SH) | 51 | File.write("#{archive_dir}/install.sh", <<-INSTALL_SH) | ||
52 | #!/bin/sh | 52 | #!/bin/sh | ||
53 | touch #{@tmpdir}/install.sh-run | 53 | touch #{@tmpdir}/install.sh-run | ||
54 | INSTALL_SH | 54 | INSTALL_SH | ||
55 | assert(system('tar', '-cf', archive, archive_dir)) | 55 | assert(system('tar', '-cf', archive, archive_dir)) | ||
56 | 56 | | |||
57 | assert(covered_system('servicemenuinstallation', archive)) | 57 | assert(system('servicemenuinstaller', 'install', archive)) | ||
58 | 58 | | |||
59 | tar_dir = "#{service_dir}/foo.tar-dir" | 59 | tar_dir = "#{service_dir}/foo.tar-dir" | ||
60 | tar_extract_dir = "#{service_dir}/foo.tar-dir/foo" | 60 | tar_extract_dir = "#{service_dir}/foo.tar-dir/foo" | ||
61 | assert_path_exist(tar_dir) | 61 | assert_path_exist(tar_dir) | ||
62 | assert_path_exist(tar_extract_dir) | 62 | assert_path_exist(tar_extract_dir) | ||
63 | assert_path_exist("#{tar_extract_dir}/install-it.sh") | 63 | assert_path_exist("#{tar_extract_dir}/install-it.sh") | ||
64 | assert_path_exist("#{tar_extract_dir}/install.sh") | 64 | assert_path_exist("#{tar_extract_dir}/install.sh") | ||
65 | end | 65 | end | ||
Show All 10 Lines | |||||
76 | if [ "$@" = "--install" ]; then | 76 | if [ "$@" = "--install" ]; then | ||
77 | touch #{@tmpdir}/install.sh-run | 77 | touch #{@tmpdir}/install.sh-run | ||
78 | exit 0 | 78 | exit 0 | ||
79 | fi | 79 | fi | ||
80 | exit 1 | 80 | exit 1 | ||
81 | INSTALL_SH | 81 | INSTALL_SH | ||
82 | assert(system('tar', '-cf', archive, archive_dir)) | 82 | assert(system('tar', '-cf', archive, archive_dir)) | ||
83 | 83 | | |||
84 | assert(covered_system('servicemenuinstallation', archive)) | 84 | assert(system('servicemenuinstaller', 'install', archive)) | ||
85 | 85 | | |||
86 | tar_dir = "#{service_dir}/foo.tar-dir" | 86 | tar_dir = "#{service_dir}/foo.tar-dir" | ||
87 | tar_extract_dir = "#{service_dir}/foo.tar-dir/foo" | 87 | tar_extract_dir = "#{service_dir}/foo.tar-dir/foo" | ||
88 | assert_path_exist(tar_dir) | 88 | assert_path_exist(tar_dir) | ||
89 | assert_path_exist(tar_extract_dir) | 89 | assert_path_exist(tar_extract_dir) | ||
90 | assert_path_not_exist("#{tar_extract_dir}/install-it.sh") | 90 | assert_path_not_exist("#{tar_extract_dir}/install-it.sh") | ||
91 | assert_path_exist("#{tar_extract_dir}/install.sh") | 91 | assert_path_exist("#{tar_extract_dir}/install.sh") | ||
92 | end | 92 | end | ||
93 | 93 | | |||
94 | def test_run_fail | 94 | def test_run_fail | ||
95 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | 95 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | ||
96 | FileUtils.mkpath(service_dir) | 96 | FileUtils.mkpath(service_dir) | ||
97 | archive = "#{service_dir}/foo.tar" | 97 | archive = "#{service_dir}/foo.tar" | ||
98 | 98 | | |||
99 | archive_dir = 'foo' # relative so tar cf is relative without fuzz | 99 | archive_dir = 'foo' # relative so tar cf is relative without fuzz | ||
100 | FileUtils.mkpath(archive_dir) | 100 | FileUtils.mkpath(archive_dir) | ||
101 | assert(system('tar', '-cf', archive, archive_dir)) | 101 | assert(system('tar', '-cf', archive, archive_dir)) | ||
102 | 102 | | |||
103 | refute(covered_system('servicemenuinstallation', archive)) | 103 | refute(system('servicemenuinstaller', 'install', archive)) | ||
104 | end | 104 | end | ||
105 | 105 | | |||
106 | def test_run_desktop | 106 | def test_run_desktop | ||
107 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | 107 | service_dir = File.join(Dir.pwd, 'share/servicemenu-download') | ||
108 | downloaded_file = "#{service_dir}/foo.desktop" | 108 | downloaded_file = "#{service_dir}/foo.desktop" | ||
109 | FileUtils.mkpath(service_dir) | 109 | FileUtils.mkpath(service_dir) | ||
110 | FileUtils.touch(downloaded_file) | 110 | FileUtils.touch(downloaded_file) | ||
111 | 111 | | |||
112 | installed_file = "#{ENV['XDG_DATA_HOME']}/kservices5/ServiceMenus/foo.desktop" | 112 | installed_file = "#{ENV['XDG_DATA_HOME']}/kservices5/ServiceMenus/foo.desktop" | ||
113 | 113 | | |||
114 | assert(covered_system('servicemenuinstallation', downloaded_file)) | 114 | assert(system('servicemenuinstaller', 'install', downloaded_file)) | ||
115 | 115 | | |||
116 | assert_path_exist(downloaded_file) | 116 | assert_path_exist(downloaded_file) | ||
117 | assert_path_exist(installed_file) | 117 | assert_path_exist(installed_file) | ||
118 | end | 118 | end | ||
119 | end | 119 | end |