Skip to content

Commit

Permalink
Merge pull request #8772 from joshcooper/main_pkg_exitstatus
Browse files Browse the repository at this point in the history
(maint) Return ProcessOutput instead of using CHILD_STATUS
  • Loading branch information
joshcooper authored Sep 29, 2021
2 parents e579347 + a410e2f commit 39aaa94
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions spec/unit/provider/package/pkg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,17 @@ def self.it_should_respond_to(*actions)
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
provider.insync?(is)
end

it "should try 5 times to install and fail when all tries failed" do
allow_any_instance_of(Kernel).to receive(:sleep)

expect(provider).to receive(:query).and_return({:ensure => :absent})
expect(provider).to receive(:properties).and_return({:mark => :hold})
expect(provider).to receive(:unhold)
expect(Puppet::Util::Execution).to receive(:execute)
.with(['/bin/pkg', 'install', *hash[:flags], 'dummy'], {:failonfail => false, :combine => true}).exactly(5).times
allow($CHILD_STATUS).to receive(:exitstatus).and_return(7)
.with(['/bin/pkg', 'install', *hash[:flags], 'dummy'], {:failonfail => false, :combine => true})
.and_return(Puppet::Util::Execution::ProcessOutput.new('', 7))
.exactly(5).times
expect {
provider.update
}.to raise_error(Puppet::Error, /Pkg could not install dummy after 5 tries. Aborting run/)
Expand Down

0 comments on commit 39aaa94

Please sign in to comment.