|
165 | 165 |
|
166 | 166 | describe "when purging" do
|
167 | 167 | it "should call pacman to remove the right package and configs quietly" do
|
168 |
| - args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-R", "--nosave", resource[:name]] |
| 168 | + args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "--remove", "--nosave", resource[:name]] |
169 | 169 | expect(executor).to receive(:execute).with(args, no_extra_options).and_return("")
|
170 | 170 | provider.purge
|
171 | 171 | end
|
172 | 172 | end
|
173 | 173 |
|
174 | 174 | describe "when uninstalling" do
|
175 | 175 | it "should call pacman to remove the right package quietly" do
|
176 |
| - args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-R", resource[:name]] |
| 176 | + args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "--remove", resource[:name]] |
177 | 177 | expect(executor).to receive(:execute).with(args, no_extra_options).and_return("")
|
178 | 178 | provider.uninstall
|
179 | 179 | end
|
180 | 180 |
|
181 | 181 | it "should call yaourt to remove the right package quietly" do
|
182 | 182 | without_partial_double_verification do
|
183 | 183 | allow(described_class).to receive(:yaourt?).and_return(true)
|
184 |
| - args = ["--noconfirm", "--noprogressbar", "-R", resource[:name]] |
| 184 | + args = ["--noconfirm", "--noprogressbar", "--remove", resource[:name]] |
185 | 185 | expect(provider).to receive(:yaourt).with(*args)
|
186 | 186 | provider.uninstall
|
187 | 187 | end
|
188 | 188 | end
|
189 | 189 |
|
190 | 190 | it "adds any uninstall_options" do
|
191 | 191 | resource[:uninstall_options] = ['-x', {'--arg' => 'value'}]
|
192 |
| - args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-x", "--arg=value", "-R", resource[:name]] |
| 192 | + args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-x", "--arg=value", "--remove", resource[:name]] |
193 | 193 | expect(executor).to receive(:execute).with(args, no_extra_options).and_return("")
|
194 | 194 | provider.uninstall
|
195 | 195 | end
|
196 | 196 |
|
197 | 197 | it "should recursively remove packages when given a package group" do
|
198 | 198 | allow(described_class).to receive(:group?).and_return(true)
|
199 |
| - args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-R", "-s", resource[:name]] |
| 199 | + args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "--remove", "-s", resource[:name]] |
200 | 200 | expect(executor).to receive(:execute).with(args, no_extra_options).and_return("")
|
201 | 201 | provider.uninstall
|
202 | 202 | end
|
203 | 203 | end
|
204 | 204 |
|
205 | 205 | describe "when querying" do
|
206 | 206 | it "should query pacman" do
|
207 |
| - expect(executor).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']) |
208 |
| - expect(executor).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg', 'package']) |
| 207 | + expect(executor).to receive(:execpipe).with(["/usr/bin/pacman", '--query']) |
| 208 | + expect(executor).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg', 'package']) |
209 | 209 | provider.query
|
210 | 210 | end
|
211 | 211 |
|
212 | 212 | it "should return the version" do
|
213 | 213 | expect(executor).to receive(:execpipe).
|
214 |
| - with(["/usr/bin/pacman", "-Q"]).and_yield(<<EOF) |
| 214 | + with(["/usr/bin/pacman", "--query"]).and_yield(<<EOF) |
215 | 215 | otherpackage 1.2.3.4
|
216 | 216 | package 1.01.3-2
|
217 | 217 | yetanotherpackage 1.2.3.4
|
218 | 218 | EOF
|
219 |
| - expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '-Sgg', 'package']).and_yield('') |
| 219 | + expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '--sync', '-gg', 'package']).and_yield('') |
220 | 220 |
|
221 | 221 | expect(provider.query).to eq({ :name => 'package', :ensure => '1.01.3-2', :provider => :pacman, })
|
222 | 222 | end
|
|
234 | 234 |
|
235 | 235 | describe 'when querying a group' do
|
236 | 236 | before :each do
|
237 |
| - expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '-Q']).and_yield('foo 1.2.3') |
238 |
| - expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '-Sgg', 'package']).and_yield('package foo') |
| 237 | + expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '--query']).and_yield('foo 1.2.3') |
| 238 | + expect(executor).to receive(:execpipe).with(['/usr/bin/pacman', '--sync', '-gg', 'package']).and_yield('package foo') |
239 | 239 | end
|
240 | 240 |
|
241 | 241 | it 'should warn when allow_virtual is false' do
|
|
254 | 254 |
|
255 | 255 | describe "when determining instances" do
|
256 | 256 | it "should retrieve installed packages and groups" do
|
257 |
| - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']) |
258 |
| - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg']) |
| 257 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--query']) |
| 258 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg']) |
259 | 259 | described_class.instances
|
260 | 260 | end
|
261 | 261 |
|
262 | 262 | it "should return installed packages" do
|
263 |
| - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']).and_yield(StringIO.new("package1 1.23-4\npackage2 2.00\n")) |
264 |
| - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg']).and_yield("") |
| 263 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--query']).and_yield(StringIO.new("package1 1.23-4\npackage2 2.00\n")) |
| 264 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg']).and_yield("") |
265 | 265 | instances = described_class.instances
|
266 | 266 |
|
267 | 267 | expect(instances.length).to eq(2)
|
|
280 | 280 | end
|
281 | 281 |
|
282 | 282 | it "should return completely installed groups with a virtual version together with packages" do
|
283 |
| - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']).and_yield(<<EOF) |
| 283 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--query']).and_yield(<<EOF) |
284 | 284 | package1 1.00
|
285 | 285 | package2 1.00
|
286 | 286 | EOF
|
287 |
| - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg']).and_yield(<<EOF) |
| 287 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg']).and_yield(<<EOF) |
288 | 288 | group1 package1
|
289 | 289 | group1 package2
|
290 | 290 | EOF
|
|
310 | 310 | end
|
311 | 311 |
|
312 | 312 | it "should not return partially installed packages" do
|
313 |
| - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Q']).and_yield(<<EOF) |
| 313 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--query']).and_yield(<<EOF) |
314 | 314 | package1 1.00
|
315 | 315 | EOF
|
316 |
| - expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '-Sgg']).and_yield(<<EOF) |
| 316 | + expect(described_class).to receive(:execpipe).with(["/usr/bin/pacman", '--sync', '-gg']).and_yield(<<EOF) |
317 | 317 | group1 package1
|
318 | 318 | group1 package2
|
319 | 319 | EOF
|
|
329 | 329 | end
|
330 | 330 |
|
331 | 331 | it 'should sort package names for installed groups' do
|
332 |
| - expect(described_class).to receive(:execpipe).with(['/usr/bin/pacman', '-Sgg', 'group1']).and_yield(<<EOF) |
| 332 | + expect(described_class).to receive(:execpipe).with(['/usr/bin/pacman', '--sync', '-gg', 'group1']).and_yield(<<EOF) |
333 | 333 | group1 aa
|
334 | 334 | group1 b
|
335 | 335 | group1 a
|
|
360 | 360 | it "should get query pacman for the latest version" do
|
361 | 361 | expect(executor).to receive(:execute).
|
362 | 362 | ordered.
|
363 |
| - with(['/usr/bin/pacman', '-Sp', '--print-format', '%v', resource[:name]], no_extra_options). |
| 363 | + with(['/usr/bin/pacman', '--sync', '--print', '--print-format', '%v', resource[:name]], no_extra_options). |
364 | 364 | and_return("")
|
365 | 365 |
|
366 | 366 | provider.latest
|
|
374 | 374 |
|
375 | 375 | it "should return a virtual group version when resource is a package group" do
|
376 | 376 | allow(described_class).to receive(:group?).and_return(true)
|
377 |
| - expect(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sp', '--print-format', '%n %v', resource[:name]], no_extra_options).ordered. |
| 377 | + expect(executor).to receive(:execute).with(['/usr/bin/pacman', '--sync', '--print', '--print-format', '%n %v', resource[:name]], no_extra_options).ordered. |
378 | 378 | and_return(<<EOF)
|
379 | 379 | package2 1.0.1
|
380 | 380 | package1 1.0.0
|
|
389 | 389 | end
|
390 | 390 |
|
391 | 391 | it 'should return false on non-zero pacman exit' do
|
392 |
| - allow(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sg', 'git'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_raise(Puppet::ExecutionFailure, 'error') |
| 392 | + allow(executor).to receive(:execute).with(['/usr/bin/pacman', '--sync', '--groups', 'git'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_raise(Puppet::ExecutionFailure, 'error') |
393 | 393 | expect(described_class.group?('git')).to eq(false)
|
394 | 394 | end
|
395 | 395 |
|
396 | 396 | it 'should return false on empty pacman output' do
|
397 |
| - allow(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sg', 'git'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_return('') |
| 397 | + allow(executor).to receive(:execute).with(['/usr/bin/pacman', '--sync', '--groups', 'git'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_return('') |
398 | 398 | expect(described_class.group?('git')).to eq(false)
|
399 | 399 | end
|
400 | 400 |
|
401 | 401 | it 'should return true on non-empty pacman output' do
|
402 |
| - allow(executor).to receive(:execute).with(['/usr/bin/pacman', '-Sg', 'vim-plugins'], {:failonfail => true, :combine => true, :custom_environment => {}}).and_return('vim-plugins vim-a') |
| 402 | + 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') |
403 | 403 | expect(described_class.group?('vim-plugins')).to eq(true)
|
404 | 404 | end
|
405 | 405 | end
|
|
409 | 409 | let(:groups) { [['foo package1'], ['foo package2'], ['bar package3'], ['bar package4'], ['baz package5']] }
|
410 | 410 |
|
411 | 411 | it 'should raise an error on non-zero pacman exit without a filter' do
|
412 |
| - expect(executor).to receive(:open).with('| /usr/bin/pacman -Sgg 2>&1').and_return('error!') |
| 412 | + expect(executor).to receive(:open).with('| /usr/bin/pacman --sync -gg 2>&1').and_return('error!') |
413 | 413 | expect(Puppet::Util::Execution).to receive(:exitstatus).and_return(1)
|
414 | 414 | expect { described_class.get_installed_groups(installed_packages) }.to raise_error(Puppet::ExecutionFailure, 'error!')
|
415 | 415 | end
|
416 | 416 |
|
417 | 417 | it 'should return empty groups on non-zero pacman exit with a filter' do
|
418 |
| - expect(executor).to receive(:open).with('| /usr/bin/pacman -Sgg git 2>&1').and_return('') |
| 418 | + expect(executor).to receive(:open).with('| /usr/bin/pacman --sync -gg git 2>&1').and_return('') |
419 | 419 | expect(Puppet::Util::Execution).to receive(:exitstatus).and_return(1)
|
420 | 420 | expect(described_class.get_installed_groups(installed_packages, 'git')).to eq({})
|
421 | 421 | end
|
422 | 422 |
|
423 | 423 | it 'should return empty groups on empty pacman output' do
|
424 | 424 | pipe = double()
|
425 | 425 | expect(pipe).to receive(:each_line)
|
426 |
| - expect(executor).to receive(:open).with('| /usr/bin/pacman -Sgg 2>&1').and_yield(pipe).and_return('') |
| 426 | + expect(executor).to receive(:open).with('| /usr/bin/pacman --sync -gg 2>&1').and_yield(pipe).and_return('') |
427 | 427 | expect(Puppet::Util::Execution).to receive(:exitstatus).and_return(0)
|
428 | 428 | expect(described_class.get_installed_groups(installed_packages)).to eq({})
|
429 | 429 | end
|
|
433 | 433 | pipe_expectation = receive(:each_line)
|
434 | 434 | groups.each { |group| pipe_expectation = pipe_expectation.and_yield(*group) }
|
435 | 435 | expect(pipe).to pipe_expectation
|
436 |
| - expect(executor).to receive(:open).with('| /usr/bin/pacman -Sgg 2>&1').and_yield(pipe).and_return('') |
| 436 | + expect(executor).to receive(:open).with('| /usr/bin/pacman --sync -gg 2>&1').and_yield(pipe).and_return('') |
437 | 437 | expect(Puppet::Util::Execution).to receive(:exitstatus).and_return(0)
|
438 | 438 | expect(described_class.get_installed_groups(installed_packages)).to eq({'foo' => 'package1 1.0, package2 2.0'})
|
439 | 439 | end
|
|
0 commit comments