|
26 | 26 | end |
27 | 27 |
|
28 | 28 | it "should call pacman to install the right package quietly when yaourt is not installed" do |
29 | | - args = ['--noconfirm', '--needed', '--noprogressbar', '-S', resource[:name]] |
| 29 | + args = ['--noconfirm', '--needed', '--noprogressbar', '--sync', resource[:name]] |
30 | 30 | expect(provider).to receive(:pacman).at_least(:once).with(*args).and_return('') |
31 | 31 | provider.install |
32 | 32 | end |
33 | 33 |
|
34 | 34 | it "should call yaourt to install the right package quietly when yaourt is installed" do |
35 | 35 | without_partial_double_verification do |
36 | 36 | allow(described_class).to receive(:yaourt?).and_return(true) |
37 | | - args = ['--noconfirm', '--needed', '--noprogressbar', '-S', resource[:name]] |
| 37 | + args = ['--noconfirm', '--needed', '--noprogressbar', '--sync', resource[:name]] |
38 | 38 | expect(provider).to receive(:yaourt).at_least(:once).with(*args).and_return('') |
39 | 39 | provider.install |
40 | 40 | end |
|
70 | 70 | end |
71 | 71 |
|
72 | 72 | it "should call pacman to install the right package quietly when yaourt is not installed" do |
73 | | - args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-S', resource[:name]] |
| 73 | + args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '--sync', resource[:name]] |
74 | 74 | expect(provider).to receive(:pacman).at_least(:once).with(*args).and_return('') |
75 | 75 | provider.install |
76 | 76 | end |
77 | 77 |
|
78 | 78 | it "should call yaourt to install the right package quietly when yaourt is installed" do |
79 | 79 | without_partial_double_verification do |
80 | 80 | expect(described_class).to receive(:yaourt?).and_return(true) |
81 | | - args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '-S', resource[:name]] |
| 81 | + args = ['--noconfirm', '--needed', '--noprogressbar', '-x', '--arg=value', '--sync', resource[:name]] |
82 | 82 | expect(provider).to receive(:yaourt).at_least(:once).with(*args).and_return('') |
83 | 83 | provider.install |
84 | 84 | end |
|
98 | 98 | resource[:source] = source |
99 | 99 |
|
100 | 100 | expect(executor).to receive(:execute). |
101 | | - with(include("-U") & include(source), no_extra_options). |
| 101 | + with(include("--update") & include(source), no_extra_options). |
102 | 102 | ordered. |
103 | 103 | and_return("") |
104 | 104 |
|
|
116 | 116 |
|
117 | 117 | it "should install from the path segment of the URL" do |
118 | 118 | expect(executor).to receive(:execute). |
119 | | - with(include("-U") & include(actual_file_path), no_extra_options). |
| 119 | + with(include("--update") & include(actual_file_path), no_extra_options). |
120 | 120 | ordered. |
121 | 121 | and_return("") |
122 | 122 |
|
|
159 | 159 |
|
160 | 160 | describe "when purging" do |
161 | 161 | it "should call pacman to remove the right package and configs quietly" do |
162 | | - args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-R", "--nosave", resource[:name]] |
| 162 | + args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "--remove", "--nosave", resource[:name]] |
163 | 163 | expect(executor).to receive(:execute).with(args, no_extra_options).and_return("") |
164 | 164 | provider.purge |
165 | 165 | end |
166 | 166 | end |
167 | 167 |
|
168 | 168 | describe "when uninstalling" do |
169 | 169 | it "should call pacman to remove the right package quietly" do |
170 | | - args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-R", resource[:name]] |
| 170 | + args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "--remove", resource[:name]] |
171 | 171 | expect(executor).to receive(:execute).with(args, no_extra_options).and_return("") |
172 | 172 | provider.uninstall |
173 | 173 | end |
174 | 174 |
|
175 | 175 | it "should call yaourt to remove the right package quietly" do |
176 | 176 | without_partial_double_verification do |
177 | 177 | allow(described_class).to receive(:yaourt?).and_return(true) |
178 | | - args = ["--noconfirm", "--noprogressbar", "-R", resource[:name]] |
| 178 | + args = ["--noconfirm", "--noprogressbar", "--remove", resource[:name]] |
179 | 179 | expect(provider).to receive(:yaourt).with(*args) |
180 | 180 | provider.uninstall |
181 | 181 | end |
182 | 182 | end |
183 | 183 |
|
184 | 184 | it "adds any uninstall_options" do |
185 | 185 | resource[:uninstall_options] = ['-x', {'--arg' => 'value'}] |
186 | | - args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-x", "--arg=value", "-R", resource[:name]] |
| 186 | + args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-x", "--arg=value", "--remove", resource[:name]] |
187 | 187 | expect(executor).to receive(:execute).with(args, no_extra_options).and_return("") |
188 | 188 | provider.uninstall |
189 | 189 | end |
190 | 190 |
|
191 | 191 | it "should recursively remove packages when given a package group" do |
192 | 192 | allow(described_class).to receive(:group?).and_return(true) |
193 | | - args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-R", "-s", resource[:name]] |
| 193 | + args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "--remove", "--recursive", resource[:name]] |
194 | 194 | expect(executor).to receive(:execute).with(args, no_extra_options).and_return("") |
195 | 195 | provider.uninstall |
196 | 196 | end |
197 | 197 | end |
198 | 198 |
|
199 | 199 | describe "when querying" do |
200 | 200 | it "should query pacman" do |
201 | | - expect(executor).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']) |
202 | | - expect(executor).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg', 'package']) |
| 201 | + expect(executor).to receive(:execpipe).with(["/usr/bin/pacman", '--query']) |
| 202 | + expect(executor).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg', 'package']) |
203 | 203 | provider.query |
204 | 204 | end |
205 | 205 |
|
206 | 206 | it "should return the version" do |
207 | 207 | expect(executor).to receive(:execpipe). |
208 | | - with(["/usr/bin/pacman", "-Q"]).and_yield(<<EOF) |
| 208 | + with(["/usr/bin/pacman", "--query"]).and_yield(<<EOF) |
209 | 209 | otherpackage 1.2.3.4 |
210 | 210 | package 1.01.3-2 |
211 | 211 | yetanotherpackage 1.2.3.4 |
212 | 212 | EOF |
213 | | - expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '-Sgg', 'package']).and_yield('') |
| 213 | + expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '--sync', '-gg', 'package']).and_yield('') |
214 | 214 |
|
215 | 215 | expect(provider.query).to eq({ :name => 'package', :ensure => '1.01.3-2', :provider => :pacman, }) |
216 | 216 | end |
|
228 | 228 |
|
229 | 229 | describe 'when querying a group' do |
230 | 230 | before :each do |
231 | | - expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '-Q']).and_yield('foo 1.2.3') |
232 | | - expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '-Sgg', 'package']).and_yield('package foo') |
| 231 | + expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '--query']).and_yield('foo 1.2.3') |
| 232 | + expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '--sync', '-gg', 'package']).and_yield('package foo') |
233 | 233 | end |
234 | 234 |
|
235 | 235 | it 'should warn when allow_virtual is false' do |
|
248 | 248 |
|
249 | 249 | describe "when determining instances" do |
250 | 250 | it "should retrieve installed packages and groups" do |
251 | | - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']) |
252 | | - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg']) |
| 251 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--query']) |
| 252 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg']) |
253 | 253 | described_class.instances |
254 | 254 | end |
255 | 255 |
|
256 | 256 | it "should return installed packages" do |
257 | | - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']).and_yield(StringIO.new("package1 1.23-4\npackage2 2.00\n")) |
258 | | - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg']).and_yield("") |
| 257 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--query']).and_yield(StringIO.new("package1 1.23-4\npackage2 2.00\n")) |
| 258 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg']).and_yield("") |
259 | 259 | instances = described_class.instances |
260 | 260 |
|
261 | 261 | expect(instances.length).to eq(2) |
|
274 | 274 | end |
275 | 275 |
|
276 | 276 | it "should return completely installed groups with a virtual version together with packages" do |
277 | | - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']).and_yield(<<EOF) |
| 277 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--query']).and_yield(<<EOF) |
278 | 278 | package1 1.00 |
279 | 279 | package2 1.00 |
280 | 280 | EOF |
281 | | - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg']).and_yield(<<EOF) |
| 281 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg']).and_yield(<<EOF) |
282 | 282 | group1 package1 |
283 | 283 | group1 package2 |
284 | 284 | EOF |
|
304 | 304 | end |
305 | 305 |
|
306 | 306 | it "should not return partially installed packages" do |
307 | | - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']).and_yield(<<EOF) |
| 307 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--query']).and_yield(<<EOF) |
308 | 308 | package1 1.00 |
309 | 309 | EOF |
310 | | - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg']).and_yield(<<EOF) |
| 310 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg']).and_yield(<<EOF) |
311 | 311 | group1 package1 |
312 | 312 | group1 package2 |
313 | 313 | EOF |
|
323 | 323 | end |
324 | 324 |
|
325 | 325 | it 'should sort package names for installed groups' do |
326 | | - expect(described_class).to receive(:execpipe).with(['/usr/bin/pacman', '-Sgg', 'group1']).and_yield(<<EOF) |
| 326 | + expect(described_class).to receive(:execpipe).with(['/usr/bin/pacman', '--sync', '-gg', 'group1']).and_yield(<<EOF) |
327 | 327 | group1 aa |
328 | 328 | group1 b |
329 | 329 | group1 a |
|
354 | 354 | it "should get query pacman for the latest version" do |
355 | 355 | expect(executor).to receive(:execute). |
356 | 356 | ordered. |
357 | | - with(['/usr/bin/pacman', '-Sp', '--print-format', '%v', resource[:name]], no_extra_options). |
| 357 | + with(['/usr/bin/pacman', '--sync', '--print', '--print-format', '%v', resource[:name]], no_extra_options). |
358 | 358 | and_return("") |
359 | 359 |
|
360 | 360 | provider.latest |
|
368 | 368 |
|
369 | 369 | it "should return a virtual group version when resource is a package group" do |
370 | 370 | allow(described_class).to receive(:group?).and_return(true) |
371 | | - expect(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sp', '--print-format', '%n %v', resource[:name]], no_extra_options).ordered. |
| 371 | + expect(executor).to receive(:execute).with(['/usr/bin/pacman', '--sync', '--print', '--print-format', '%n %v', resource[:name]], no_extra_options).ordered. |
372 | 372 | and_return(<<EOF) |
373 | 373 | package2 1.0.1 |
374 | 374 | package1 1.0.0 |
|
383 | 383 | end |
384 | 384 |
|
385 | 385 | it 'should return false on non-zero pacman exit' do |
386 | | - allow(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sg', 'git'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_raise(Puppet::ExecutionFailure, 'error') |
| 386 | + allow(executor).to receive(:execute).with(['/usr/bin/pacman', '--sync', '--groups', 'git'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_raise(Puppet::ExecutionFailure, 'error') |
387 | 387 | expect(described_class.group?('git')).to eq(false) |
388 | 388 | end |
389 | 389 |
|
390 | 390 | it 'should return false on empty pacman output' do |
391 | | - allow(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sg', 'git'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_return('') |
| 391 | + allow(executor).to receive(:execute).with(['/usr/bin/pacman', '--sync', '--groups', 'git'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_return('') |
392 | 392 | expect(described_class.group?('git')).to eq(false) |
393 | 393 | end |
394 | 394 |
|
395 | 395 | it 'should return true on non-empty pacman output' do |
396 | | - allow(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sg', 'vim-plugins'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_return('vim-plugins vim-a') |
| 396 | + allow(executor).to receive(:execute).with(['/usr/bin/pacman', '--sync', '--groups', 'vim-plugins'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_return('vim-plugins vim-a') |
397 | 397 | expect(described_class.group?('vim-plugins')).to eq(true) |
398 | 398 | end |
399 | 399 | end |
|
403 | 403 | let(:groups) { [['foo package1'], ['foo package2'], ['bar package3'], ['bar package4'], ['baz package5']] } |
404 | 404 |
|
405 | 405 | it 'should raise an error on non-zero pacman exit without a filter' do |
406 | | - expect(executor).to receive(:open).with('| /usr/bin/pacman -Sgg 2>&1').and_return('error!') |
| 406 | + expect(executor).to receive(:open).with('| /usr/bin/pacman --sync -gg 2>&1').and_return('error!') |
407 | 407 | expect(Puppet::Util::Execution).to receive(:exitstatus).and_return(1) |
408 | 408 | expect { described_class.get_installed_groups(installed_packages) }.to raise_error(Puppet::ExecutionFailure, 'error!') |
409 | 409 | end |
410 | 410 |
|
411 | 411 | it 'should return empty groups on non-zero pacman exit with a filter' do |
412 | | - expect(executor).to receive(:open).with('| /usr/bin/pacman -Sgg git 2>&1').and_return('') |
| 412 | + expect(executor).to receive(:open).with('| /usr/bin/pacman --sync -gg git 2>&1').and_return('') |
413 | 413 | expect(Puppet::Util::Execution).to receive(:exitstatus).and_return(1) |
414 | 414 | expect(described_class.get_installed_groups(installed_packages, 'git')).to eq({}) |
415 | 415 | end |
416 | 416 |
|
417 | 417 | it 'should return empty groups on empty pacman output' do |
418 | 418 | pipe = double() |
419 | 419 | expect(pipe).to receive(:each_line) |
420 | | - expect(executor).to receive(:open).with('| /usr/bin/pacman -Sgg 2>&1').and_yield(pipe).and_return('') |
| 420 | + expect(executor).to receive(:open).with('| /usr/bin/pacman --sync -gg 2>&1').and_yield(pipe).and_return('') |
421 | 421 | expect(Puppet::Util::Execution).to receive(:exitstatus).and_return(0) |
422 | 422 | expect(described_class.get_installed_groups(installed_packages)).to eq({}) |
423 | 423 | end |
|
427 | 427 | pipe_expectation = receive(:each_line) |
428 | 428 | groups.each { |group| pipe_expectation = pipe_expectation.and_yield(*group) } |
429 | 429 | expect(pipe).to pipe_expectation |
430 | | - expect(executor).to receive(:open).with('| /usr/bin/pacman -Sgg 2>&1').and_yield(pipe).and_return('') |
| 430 | + expect(executor).to receive(:open).with('| /usr/bin/pacman --sync -gg 2>&1').and_yield(pipe).and_return('') |
431 | 431 | expect(Puppet::Util::Execution).to receive(:exitstatus).and_return(0) |
432 | 432 | expect(described_class.get_installed_groups(installed_packages)).to eq({'foo' => 'package1 1.0, package2 2.0'}) |
433 | 433 | end |
|
0 commit comments