kanrisuru 0.16.0 → 0.16.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/lib/kanrisuru/command.rb +2 -3
  4. data/lib/kanrisuru/core/zypper/commands/add_repo.rb +1 -8
  5. data/lib/kanrisuru/core/zypper/commands/add_service.rb +4 -2
  6. data/lib/kanrisuru/core/zypper/commands/info.rb +1 -2
  7. data/lib/kanrisuru/core/zypper/commands/install.rb +2 -3
  8. data/lib/kanrisuru/core/zypper/commands/modify_repo.rb +1 -7
  9. data/lib/kanrisuru/core/zypper/commands/modify_service.rb +3 -1
  10. data/lib/kanrisuru/core/zypper/commands/remove.rb +1 -2
  11. data/lib/kanrisuru/core/zypper/commands/remove_repo.rb +3 -3
  12. data/lib/kanrisuru/core/zypper/commands/remove_service.rb +6 -1
  13. data/lib/kanrisuru/core/zypper/commands/search.rb +1 -3
  14. data/lib/kanrisuru/core/zypper/commands/source_install.rb +2 -0
  15. data/lib/kanrisuru/core/zypper/commands.rb +10 -1
  16. data/lib/kanrisuru/mode/permission.rb +103 -0
  17. data/lib/kanrisuru/mode.rb +2 -98
  18. data/lib/kanrisuru/os_package.rb +2 -0
  19. data/lib/kanrisuru/remote/fstab/entry.rb +154 -0
  20. data/lib/kanrisuru/remote/fstab/options.rb +143 -0
  21. data/lib/kanrisuru/remote/fstab.rb +3 -283
  22. data/lib/kanrisuru/remote/host.rb +1 -3
  23. data/lib/kanrisuru/version.rb +1 -1
  24. data/spec/functional/core/{ip/ip_address_label_spec.rb → ip_address_label_spec.rb} +0 -0
  25. data/spec/functional/core/{ip/ip_address_spec.rb → ip_address_spec.rb} +0 -0
  26. data/spec/functional/core/{ip/ip_link_spec.rb → ip_link_spec.rb} +0 -0
  27. data/spec/functional/core/{ip/ip_maddress_spec.rb → ip_maddress_spec.rb} +0 -0
  28. data/spec/functional/core/{ip/ip_neighbour_spec.rb → ip_neighbour_spec.rb} +0 -0
  29. data/spec/functional/core/{ip/ip_route_spec.rb → ip_route_spec.rb} +0 -0
  30. data/spec/functional/core/{ip/ip_rule_spec.rb → ip_rule_spec.rb} +0 -0
  31. data/spec/functional/core/{ip/ip_spec.rb → ip_spec.rb} +0 -0
  32. data/spec/functional/core/zypper_spec.rb +708 -0
  33. data/spec/helper/stub_network.rb +1 -1
  34. metadata +14 -10
@@ -0,0 +1,708 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Zypper do
6
+ before(:all) do
7
+ StubNetwork.stub!(:opensuse)
8
+ end
9
+
10
+ after(:all) do
11
+ StubNetwork.unstub!
12
+ end
13
+
14
+ let(:host) do
15
+ Kanrisuru::Remote::Host.new(
16
+ host: 'opensuse-host',
17
+ username: 'opensuse',
18
+ keys: ['id_rsa']
19
+ )
20
+ end
21
+
22
+ %w[addlock al].each do |action_variant|
23
+ it "prepares #{action_variant} command" do
24
+ expect_command(host.zypper(action_variant, lock: 'nginx'),
25
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev addlock nginx')
26
+
27
+ expect_command(host.zypper(action_variant,
28
+ lock: 'nginx',
29
+ type: 'package',
30
+ config_file: '/etc/zypp/zypp.conf'),
31
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --config /etc/zypp/zypp.conf addlock -t package nginx')
32
+ end
33
+ end
34
+
35
+ %w[locks ll].each do |action_variant|
36
+ it "prepares #{action_variant} command" do
37
+ expect_command(host.zypper(action_variant),
38
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet locks --matches')
39
+ end
40
+ end
41
+
42
+ %w[removelock rl].each do |action_variant|
43
+ it "prepares #{action_variant} command" do
44
+ expect_command(host.zypper(action_variant, lock: 'gcc'),
45
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev removelock gcc')
46
+
47
+ expect_command(host.zypper(action_variant, lock: 'gcc', type: 'patch'),
48
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev removelock -t patch gcc')
49
+ end
50
+ end
51
+
52
+ %w[cleanlocks cl].each do |action_variant|
53
+ it "prepares #{action_variant} command" do
54
+ expect_command(host.zypper(action_variant),
55
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev cleanlocks')
56
+ end
57
+ end
58
+
59
+ %w[repos lr].each do |action_variant|
60
+ it "prepares #{action_variant} command" do
61
+ expect_command(host.zypper(action_variant),
62
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev repos --details')
63
+ end
64
+ end
65
+
66
+ %w[refresh ref].each do |action_variant|
67
+ it "prepares #{action_variant} command" do
68
+ expect_command(host.zypper(action_variant),
69
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev refresh')
70
+
71
+ expect_command(host.zypper(action_variant,
72
+ force: true,
73
+ force_build: true,
74
+ force_download: true,
75
+ build_only: true,
76
+ download_only: true),
77
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev refresh --force --force-build --force-download --build-only --download-only')
78
+ end
79
+ end
80
+
81
+ %w[modifyrepo mr].each do |action_variant|
82
+ it "prepares #{action_variant} command" do
83
+ expect_command(host.zypper(action_variant, repos: 'graphics'),
84
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo graphics')
85
+
86
+ expect_command(host.zypper(action_variant,
87
+ repos: 'graphics',
88
+ name: 'graphics-alias',
89
+ priority: 1),
90
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo --name graphics-alias --priority 1 graphics')
91
+
92
+ expect_command(host.zypper(action_variant,
93
+ disable: true,
94
+ remote: true),
95
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo --disable --remote')
96
+
97
+ expect_command(host.zypper(action_variant,
98
+ enable: true,
99
+ local: true),
100
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo --enable --local')
101
+
102
+ expect_command(host.zypper(action_variant,
103
+ refresh: true,
104
+ all: true),
105
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo --refresh --all')
106
+
107
+ expect_command(host.zypper(action_variant,
108
+ no_refresh: true,
109
+ all: true),
110
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo --no-refresh --all')
111
+
112
+ expect_command(host.zypper(action_variant,
113
+ keep_packages: true,
114
+ all: true),
115
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo --keep-packages --all')
116
+
117
+ expect_command(host.zypper(action_variant,
118
+ no_keep_packages: true,
119
+ all: true),
120
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo --no-keep-packages --all')
121
+
122
+ expect_command(host.zypper(action_variant,
123
+ gpgcheck: true,
124
+ gpgcheck_strict: true,
125
+ gpgcheck_allow_unsigned: true,
126
+ gpgcheck_allow_unsigned_repo: true,
127
+ gpgcheck_allow_unsigned_package: true,
128
+ default_gpgcheck: true),
129
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo --gpgcheck --gpgcheck-strict --gpgcheck-allow-unsigned --gpgcheck-allow-unsigned-repo --gpgcheck-allow-unsigned-package --default-gpgcheck')
130
+
131
+ expect_command(host.zypper(action_variant,
132
+ medium_type: 'file'),
133
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyrepo --medium-type file')
134
+
135
+ expect do
136
+ host.zypper(action_variant, medium_type: 'tap')
137
+ end.to raise_error(ArgumentError)
138
+ end
139
+ end
140
+
141
+ %w[addrepo ar].each do |action_variant|
142
+ it "prepares #{action_variant} command" do
143
+ expect_command(host.zypper(action_variant, repos: 'graphics'),
144
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev addrepo --repo graphics')
145
+
146
+ expect_command(host.zypper(action_variant, repos: %w[graphics repo-debug]),
147
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev addrepo --repo graphics --repo repo-debug')
148
+
149
+ expect_command(host.zypper(action_variant,
150
+ check: true,
151
+ enable: true,
152
+ refresh: true,
153
+ keep_packages: true,
154
+ gpgcheck: true,
155
+ gpgcheck_strict: true,
156
+ gpgcheck_allow_unsigned: true,
157
+ gpgcheck_allow_unsigned_repo: true,
158
+ gpgcheck_allow_unsigned_package: true,
159
+ default_gpgcheck: true,
160
+ repos: 'graphics'),
161
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev addrepo --check --enable --refresh --keep-packages --gpgcheck --gpgcheck-strict --gpgcheck-allow-unsigned --gpgcheck-allow-unsigned-repo --gpgcheck-allow-unsigned-package --default-gpgcheck --repo graphics')
162
+
163
+ expect_command(host.zypper(action_variant,
164
+ no_check: true,
165
+ disable: true,
166
+ no_refresh: true,
167
+ no_keep_packages: true,
168
+ priority: true,
169
+ no_gpgcheck: true,
170
+ repos: 'graphics'), 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev addrepo --no-check --disable --no-refresh --no-keep-packages --priority true --no-gpgcheck --repo graphics')
171
+ end
172
+ end
173
+
174
+ %w[removerepo rr].each do |action_variant|
175
+ it "prepares #{action_variant} command" do
176
+ expect_command(host.zypper(action_variant, repos: 'graphics'),
177
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev removerepo graphics')
178
+
179
+ expect_command(host.zypper(action_variant,
180
+ repos: %w[graphics repo-debug],
181
+ loose_auth: true,
182
+ loose_query: true,
183
+ all: true,
184
+ medium_type: 'nfs'),
185
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev removerepo --loose-auth --loose-query --all --medium-type nfs graphics repo-debug')
186
+
187
+ expect_command(host.zypper(action_variant,
188
+ repos: %w[graphics repo-debug],
189
+ local: true,
190
+ remote: true),
191
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev removerepo --local --remote graphics repo-debug')
192
+
193
+ expect do
194
+ host.zypper(action_variant, repos: %w[graphics repo-debug], medium_type: 'floppy')
195
+ end.to raise_error(ArgumentError)
196
+ end
197
+ end
198
+
199
+ %w[renamerepo nr].each do |action_variant|
200
+ it "prepares #{action_variant} command" do
201
+ expect_command(host.zypper(action_variant, repo: 'graphics', alias: 'graphics-alias'),
202
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev renamerepo graphics graphics-alias')
203
+ end
204
+ end
205
+
206
+ %w[addservice as].each do |action_variant|
207
+ it "prepares #{action_variant} command" do
208
+ expect_command(host.zypper(action_variant,
209
+ service: 'https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/',
210
+ alias: 'repo-database'),
211
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev addservice https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/ repo-database')
212
+
213
+ expect_command(host.zypper(action_variant,
214
+ service: 'https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/',
215
+ alias: 'repo-database',
216
+ disable: true,
217
+ refresh: true),
218
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev addservice --disable --refresh https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/ repo-database')
219
+
220
+ expect_command(host.zypper(action_variant,
221
+ service: 'https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/',
222
+ name: 'Database Repository',
223
+ enable: true,
224
+ no_refresh: true,
225
+ alias: 'repo-database'),
226
+ "zypper --non-interactive --ignore-unknown --no-color --no-abbrev addservice --name 'Database Repository' --enable --no-refresh https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/ repo-database")
227
+ end
228
+ end
229
+
230
+ %w[removeservice rs].each do |action_variant|
231
+ it "prepares #{action_variant} command" do
232
+ expect_command(host.zypper(action_variant, service: 'repo-source-non-oss'),
233
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev removeservice repo-source-non-oss')
234
+
235
+ expect_command(host.zypper(action_variant,
236
+ loose_auth: true,
237
+ loose_query: true,
238
+ service: 'https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/'),
239
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev removeservice --loose-auth --loose-query https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/')
240
+
241
+ expect_command(host.zypper(action_variant, service: 'Debug Repository (Non-OSS)'),
242
+ "zypper --non-interactive --ignore-unknown --no-color --no-abbrev removeservice 'Debug Repository (Non-OSS)'")
243
+ end
244
+ end
245
+
246
+ %w[modifyservice ms].each do |action_variant|
247
+ it "prepares #{action_variant} command" do
248
+ expect_command(host.zypper(action_variant, service: 'repo-database', no_refresh: true, enable: true),
249
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --enable --no-refresh repo-database')
250
+
251
+ expect_command(host.zypper(action_variant,
252
+ service: 'https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/',
253
+ name: "'Database Repository OSS'",
254
+ disable: true,
255
+ refresh: true),
256
+ "zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --name 'Database Repository OSS' --disable --refresh https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/")
257
+
258
+ expect_command(host.zypper(action_variant,
259
+ all: true),
260
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --all')
261
+
262
+ expect_command(host.zypper(action_variant,
263
+ local: true),
264
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --local')
265
+
266
+ expect_command(host.zypper(action_variant,
267
+ remote: true),
268
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --remote')
269
+
270
+ expect_command(host.zypper(action_variant,
271
+ medium_type: 'http',
272
+ disable: true),
273
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --disable --medium-type http')
274
+
275
+ expect do
276
+ host.zypper(action_variant, medium_type: 'rar')
277
+ end.to raise_error(ArgumentError)
278
+
279
+ expect_command(host.zypper(action_variant,
280
+ ar_to_enable: 'SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool'),
281
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --ar-to-enable SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool')
282
+
283
+ expect_command(host.zypper(action_variant,
284
+ ar_to_disable: 'SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool'),
285
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --ar-to-disable SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool')
286
+
287
+ expect_command(host.zypper(action_variant,
288
+ rr_to_enable: 'SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool'),
289
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --rr-to-enable SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool')
290
+
291
+ expect_command(host.zypper(action_variant,
292
+ rr_to_disable: 'SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool'),
293
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --rr-to-disable SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool')
294
+
295
+ expect_command(host.zypper(action_variant,
296
+ cl_to_enable: 'SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool'),
297
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --cl-to-enable SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool')
298
+
299
+ expect_command(host.zypper(action_variant,
300
+ cl_to_disable: 'SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool'),
301
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev modifyservice --cl-to-disable SMT-http_usanlx_pc_corp_com:SLES11-SP2-pool')
302
+ end
303
+ end
304
+
305
+ %w[services ls].each do |action_variant|
306
+ it "prepares #{action_variant} command" do
307
+ expect_command(host.zypper(action_variant),
308
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev services --details')
309
+ end
310
+ end
311
+
312
+ %w[refresh-services refs].each do |action_variant|
313
+ it "prepares #{action_variant} command" do
314
+ expect_command(host.zypper(action_variant),
315
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev refresh-services')
316
+
317
+ expect_command(host.zypper(action_variant, force: true, with_repos: true, restore_status: true),
318
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev refresh-services --force --with-repos --restore-status')
319
+ end
320
+ end
321
+
322
+ %w[info if].each do |action_variant|
323
+ it "prepares #{action_variant} command" do
324
+ expect_command(host.zypper(action_variant, packages: 'workrave'),
325
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev info workrave')
326
+
327
+ expect_command(host.zypper(action_variant, packages: %w[nginx curl]),
328
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev info nginx curl')
329
+
330
+ expect_command(host.zypper(action_variant, packages: 'go', type: 'package'),
331
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev info -t package go')
332
+
333
+ expect_command(host.zypper(action_variant, packages: %w[ffmpeg gcc], repos: 'repo-oss'),
334
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev info --repo repo-oss ffmpeg gcc')
335
+
336
+ expect_command(host.zypper(action_variant, packages: %w[ffmpeg gcc], repos: %w[repo-oss packman]),
337
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev info --repo repo-oss --repo packman ffmpeg gcc')
338
+ end
339
+ end
340
+
341
+ %w[install in].each do |action_variant|
342
+ it "prepares #{action_variant} command" do
343
+ expect_command(host.zypper(action_variant, packages: 'nginx'),
344
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev install nginx')
345
+
346
+ expect_command(host.zypper(action_variant,
347
+ packages: %w[nginx curl],
348
+ repos: 'repo-oss',
349
+ oldpackage: true,
350
+ auto_agree_with_licenses: true,
351
+ auto_agree_with_product_licenses: true,
352
+ replacefiles: true,
353
+ dry_run: true,
354
+ allow_unsigned_rpm: true),
355
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev install --repo repo-oss --oldpackage --auto-agree-with-licenses --auto-agree-with-product-licenses --replacefiles --dry-run --allow-unsigned-rpm nginx curl')
356
+
357
+ expect_command(host.zypper(action_variant,
358
+ name: 'nginx',
359
+ force: true),
360
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev install -n nginx -f')
361
+
362
+ expect_command(host.zypper(action_variant,
363
+ name: 'nginx',
364
+ force: true,
365
+ download_only: true,
366
+ download_in_advance: true,
367
+ download_in_heaps: true,
368
+ download_as_needed: true),
369
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev install -n nginx -f --download-only --download-in-advance --download-in-heaps --download-as-needed')
370
+
371
+ expect_command(host.zypper(action_variant,
372
+ type: 'srcpackage',
373
+ allow_unsigned_rpm: true,
374
+ allow_downgrade: true,
375
+ allow_name_change: true,
376
+ allow_arch_change: true,
377
+ allow_vendor_change: true,
378
+ debug_solver: true,
379
+ force_resolution: true,
380
+ solver_focus_mode: 'update',
381
+ clean_deps: true),
382
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev install -t srcpackage --allow-unsigned-rpm --debug-solver --force-resolution --solver-focus update --clean-deps --allow-downgrade --allow-name-change --allow-arch-change --allow-vendor-change')
383
+
384
+ expect_command(host.zypper(action_variant,
385
+ from: 'https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/',
386
+ capability: true,
387
+ no_force_resolution: true,
388
+ no_allow_downgrade: true,
389
+ no_allow_name_change: true,
390
+ no_allow_arch_change: true,
391
+ no_allow_vendor_change: true),
392
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev install --from https://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.2/ --capability true --no-force-resolution --no-allow-downgrade --no-allow-name-change --no-allow-arch-change --no-allow-vendor-change')
393
+ end
394
+ end
395
+
396
+ %w[source-install si].each do |action_variant|
397
+ it "prepares #{action_variant} command" do
398
+ expect_command(host.zypper(action_variant, packages: 'python-pip', build_deps_only: true),
399
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev sourceinstall --build-deps-only python-pip')
400
+
401
+ expect_command(host.zypper(action_variant,
402
+ packages: %w[python-pip i2c-tools],
403
+ no_build_deps_only: true,
404
+ download_only: true),
405
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev sourceinstall --download-only python-pip i2c-tools')
406
+
407
+ expect_command(host.zypper(action_variant, repos: 'packman', packages: 'bind'),
408
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev sourceinstall --repo packman bind')
409
+
410
+ expect_command(host.zypper(action_variant, repos: %w[packman repo-oss], packages: %w[bind apache2]),
411
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev sourceinstall --repo packman --repo repo-oss bind apache2')
412
+ end
413
+ end
414
+
415
+ %w[verify ve].each do |action_variant|
416
+ it "prepares #{action_variant} command" do
417
+ expect_command(host.zypper(action_variant),
418
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev verify')
419
+
420
+ expect_command(host.zypper(action_variant, dry_run: true, repos: 'repo-oss'),
421
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev verify --dry-run --repo repo-oss')
422
+
423
+ expect_command(host.zypper(action_variant, dry_run: true, repos: %w[repo-oss packman]),
424
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev verify --dry-run --repo repo-oss --repo packman')
425
+ end
426
+ end
427
+
428
+ %w[install-new-recommends inr].each do |action_variant|
429
+ it "prepares #{action_variant} command" do
430
+ expect_command(host.zypper(action_variant),
431
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev install-new-recommends')
432
+
433
+ expect_command(host.zypper(action_variant, dry_run: true, repos: 'repo-update'),
434
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev install-new-recommends --dry-run --repo repo-update')
435
+
436
+ expect_command(host.zypper(action_variant, repos: %w[repo-update repo-update-non-oss]),
437
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev install-new-recommends --repo repo-update --repo repo-update-non-oss')
438
+ end
439
+ end
440
+
441
+ %w[remove rm].each do |action_variant|
442
+ it "prepares #{action_variant} command" do
443
+ expect_command(host.zypper(action_variant, packages: 'nginx'),
444
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev remove nginx')
445
+
446
+ expect_command(host.zypper(action_variant,
447
+ packages: %w[nginx apache2 curl],
448
+ dry_run: true,
449
+ capability: true,
450
+ repos: %w[packman repo-update repo-oss]),
451
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev remove --dry-run --capability --repo packman --repo repo-update --repo repo-oss nginx apache2 curl')
452
+ end
453
+ end
454
+
455
+ it 'prepares purge-kernels command' do
456
+ expect_command(host.zypper('purge-kernels'),
457
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev purge-kernels')
458
+ expect_command(host.zypper('purge-kernels', dry_run: true),
459
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev purge-kernels --dry-run')
460
+ end
461
+
462
+ %w[search se].each do |action_variant|
463
+ it "prepares #{action_variant} command" do
464
+ expect_command(host.zypper(action_variant, packages: 'nginx'),
465
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev search --details nginx')
466
+
467
+ expect_command(host.zypper(action_variant, packages: %w[nginx curl], match_exact: true),
468
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev search --details --match-exact nginx curl')
469
+
470
+ expect_command(host.zypper(action_variant,
471
+ packages: %w[nginx curl],
472
+ match_substrings: true,
473
+ match_words: true,
474
+ provides: true,
475
+ requires: true,
476
+ recommends: true,
477
+ suggests: true,
478
+ conflicts: true,
479
+ obsoletes: true),
480
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev search --details --match-substrings --match-words --provides --requires --recommends --suggests --conflicts --obsoletes nginx curl')
481
+
482
+ expect_command(host.zypper(action_variant,
483
+ packages: %w[kernel gcc],
484
+ installed_only: true,
485
+ sort_by_repo: true,
486
+ supplements: true,
487
+ provides_pkg: true,
488
+ requires_pkg: true,
489
+ recommends_pkg: true,
490
+ supplements_pkg: true,
491
+ conflicts_pkg: true,
492
+ obsoletes_pkg: true,
493
+ suggests_pkg: true), 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev search --details --supplements --provides-pkg --requires-pkg --recommends-pkg --supplements-pkg --conflicts-pkg --obsoletes-pkg --suggests-pkg --installed-only --sort-by-repo kernel gcc')
494
+
495
+ expect_command(host.zypper(action_variant,
496
+ packages: %w[kernel gcc],
497
+ name: true,
498
+ file_list: true,
499
+ search_descriptions: true,
500
+ case_sensitive: true,
501
+ not_installed_only: true,
502
+ sort_by_name: true),
503
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev search --details --name --file-list --search-descriptions --case-sensitive --not-installed-only --sort-by-name kernel gcc')
504
+ end
505
+ end
506
+
507
+ %w[clean cc].each do |action_variant|
508
+ it "prepares #{action_variant} command" do
509
+ expect_command(host.zypper(action_variant),
510
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev clean')
511
+
512
+ expect_command(host.zypper(action_variant, all: true),
513
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev clean --all')
514
+
515
+ expect_command(host.zypper(action_variant, repos: 'pacman'),
516
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev clean pacman')
517
+
518
+ expect_command(host.zypper(action_variant, repos: %w[pacman repo-oss]),
519
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev clean pacman repo-oss')
520
+
521
+ expect_command(host.zypper(action_variant, metadata: true, raw_metadata: true),
522
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev clean --metadata --raw-metadata')
523
+ end
524
+ end
525
+
526
+ %w[list-updates lu].each do |action_variant|
527
+ it "prepares #{action_variant} command" do
528
+ expect_command(host.zypper(action_variant),
529
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-updates')
530
+
531
+ expect_command(host.zypper(action_variant,
532
+ repos: 'repo-source-non-oss',
533
+ type: 'application',
534
+ all: true,
535
+ best_effort: true),
536
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-updates --repo repo-source-non-oss -t application --all --best-effort')
537
+
538
+ expect_command(host.zypper(action_variant, type: 'patch'),
539
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches')
540
+ end
541
+ end
542
+
543
+ %w[list-patches lp].each do |action_variant|
544
+ it "prepares #{action_variant} command" do
545
+ expect_command(host.zypper(action_variant),
546
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches')
547
+
548
+ expect_command(host.zypper(action_variant, bugzilla: '972197'),
549
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --bugzilla 972197')
550
+
551
+ expect_command(host.zypper(action_variant, cve: 'CVE-2016-2315'),
552
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --cve CVE-2016-2315')
553
+
554
+ expect_command(host.zypper(action_variant, date: '2021-12-31'),
555
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --date 2021-12-31')
556
+
557
+ expect_command(host.zypper(action_variant, without_optional: true),
558
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --without-optional')
559
+
560
+ expect_command(host.zypper(action_variant, issues: true),
561
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --issues')
562
+
563
+ expect_command(host.zypper(action_variant, all: true),
564
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --all')
565
+
566
+ expect_command(host.zypper(action_variant, with_optional: true),
567
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --with-optional')
568
+
569
+ expect_command(host.zypper(action_variant, without_optional: true),
570
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --without-optional')
571
+
572
+ expect_command(host.zypper(action_variant, category: 'security'),
573
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --category security')
574
+
575
+ expect_command(host.zypper(action_variant, category: %w[security recommended optional feature]),
576
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --category security --category recommended --category optional --category feature')
577
+
578
+ expect_command(host.zypper(action_variant, severity: 'low'),
579
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --severity low')
580
+
581
+ expect_command(host.zypper(action_variant, severity: %w[critical important moderate]),
582
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --severity critical --severity important --severity moderate')
583
+
584
+ expect_command(host.zypper(action_variant,
585
+ category: %w[security recommended optional feature],
586
+ severity: %w[critical important moderate],
587
+ repos: %w[packman repo-oss]),
588
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet list-patches --category security --category recommended --category optional --category feature --severity critical --severity important --severity moderate --repo packman --repo repo-oss')
589
+ end
590
+ end
591
+
592
+ %w[patch-check pchk].each do |action_variant|
593
+ it "prepares #{action_variant} command" do
594
+ expect_command(host.zypper(action_variant),
595
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet patch-check')
596
+
597
+ expect_command(host.zypper(action_variant, without_optional: true),
598
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet patch-check --without-optional')
599
+
600
+ expect_command(host.zypper(action_variant, updatestack_only: true, with_optional: true),
601
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet patch-check --updatestack-only --with-optional')
602
+
603
+ expect_command(host.zypper(action_variant, updatestack_only: true, with_optional: true),
604
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev --quiet patch-check --updatestack-only --with-optional')
605
+ end
606
+ end
607
+
608
+ it 'prepares patch command' do
609
+ expect_command(host.zypper('patch'), 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch')
610
+ expect_command(host.zypper('patch',
611
+ updatestack_only: true,
612
+ with_update: true,
613
+ with_optional: true,
614
+ replacefiles: true,
615
+ dry_run: true),
616
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --updatestack-only --with-update --with-optional --replacefiles --dry-run')
617
+
618
+ expect_command(host.zypper('patch',
619
+ auto_agree_with_licenses: true,
620
+ auto_agree_with_product_licenses: true),
621
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --auto-agree-with-licenses --auto-agree-with-product-licenses')
622
+
623
+ expect_command(host.zypper('patch', bugzilla: '972197'),
624
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --bugzilla 972197')
625
+
626
+ expect_command(host.zypper('patch', cve: 'CVE-2016-2315'),
627
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --cve CVE-2016-2315')
628
+
629
+ expect_command(host.zypper('patch', date: '2021-12-31'),
630
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --date 2021-12-31')
631
+
632
+ expect_command(host.zypper('patch', category: 'security'),
633
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --category security')
634
+
635
+ expect_command(host.zypper('patch', category: %w[security recommended optional feature]),
636
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --category security --category recommended --category optional --category feature')
637
+
638
+ expect_command(host.zypper('patch', severity: 'low'),
639
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --severity low')
640
+
641
+ expect_command(host.zypper('patch', severity: %w[critical important moderate]),
642
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --severity critical --severity important --severity moderate')
643
+
644
+ expect_command(host.zypper('patch',
645
+ category: %w[security recommended optional feature],
646
+ severity: %w[critical important moderate],
647
+ repos: %w[packman repo-oss],
648
+ debug_solver: true,
649
+ force_resolution: true,
650
+ allow_downgrade: true,
651
+ allow_name_change: true,
652
+ allow_arch_change: true,
653
+ allow_vendor_change: true),
654
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev patch --category security --category recommended --category optional --category feature --severity critical --severity important --severity moderate --repo packman --repo repo-oss --debug-solver --force-resolution --allow-downgrade --allow-name-change --allow-arch-change --allow-vendor-change')
655
+ end
656
+
657
+ %w[dist-upgrade dup].each do |action_variant|
658
+ it "prepares #{action_variant} command" do
659
+ expect_command(host.zypper(action_variant),
660
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev dist-upgrade')
661
+
662
+ expect_command(host.zypper(action_variant, dry_run: true),
663
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev dist-upgrade --dry-run')
664
+
665
+ expect_command(host.zypper(action_variant, auto_agree_with_licenses: true, auto_agree_with_product_licenses: true),
666
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev dist-upgrade --auto-agree-with-licenses --auto-agree-with-product-licenses')
667
+
668
+ expect_command(host.zypper(action_variant, dry_run: true, repos: 'pacman'),
669
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev dist-upgrade --dry-run --repo pacman')
670
+
671
+ expect_command(host.zypper(action_variant,
672
+ repos: %w[packman repo-oss],
673
+ debug_solver: true,
674
+ force_resolution: true,
675
+ allow_downgrade: true,
676
+ allow_name_change: true,
677
+ allow_arch_change: true,
678
+ allow_vendor_change: true),
679
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev dist-upgrade --repo packman --repo repo-oss --debug-solver --force-resolution --allow-downgrade --allow-name-change --allow-arch-change --allow-vendor-change')
680
+ end
681
+ end
682
+
683
+ %w[update up].each do |action_variant|
684
+ it "prepares #{action_variant} command" do
685
+ expect_command(host.zypper(action_variant),
686
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev update')
687
+
688
+ expect_command(host.zypper(action_variant, repos: 'repo-debug-non-oss', type: 'package'),
689
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev update --repo repo-debug-non-oss -t package')
690
+
691
+ expect_command(host.zypper(action_variant,
692
+ repos: %w[repo-debug-non-oss repo-non-oss],
693
+ replacefiles: true,
694
+ best_effort: true,
695
+ dry_run: true),
696
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev update --repo repo-debug-non-oss --repo repo-non-oss --replacefiles --dry-run --best-effort')
697
+
698
+ expect_command(host.zypper(action_variant,
699
+ debug_solver: true,
700
+ force_resolution: true,
701
+ allow_downgrade: true,
702
+ allow_name_change: true,
703
+ allow_arch_change: true,
704
+ allow_vendor_change: true),
705
+ 'zypper --non-interactive --ignore-unknown --no-color --no-abbrev update --debug-solver --force-resolution --allow-downgrade --allow-name-change --allow-arch-change --allow-vendor-change')
706
+ end
707
+ end
708
+ end