diff options
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/type/exec.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/unit/type/exec.rb b/spec/unit/type/exec.rb index 816e01bcc..761d41403 100755 --- a/spec/unit/type/exec.rb +++ b/spec/unit/type/exec.rb @@ -3,11 +3,11 @@ require File.dirname(__FILE__) + '/../../spec_helper' module ExecModuleTesting - def create_resource(command, output, exitstatus) + def create_resource(command, output, exitstatus, returns = [0]) @user_name = 'some_user_name' @group_name = 'some_group_name' Puppet.features.stubs(:root?).returns(true) - @execer = Puppet::Type.type(:exec).new(:name => command, :path => %w{/usr/bin /bin}, :user => @user_name, :group => @group_name) + @execer = Puppet::Type.type(:exec).new(:name => command, :path => %w{/usr/bin /bin}, :user => @user_name, :group => @group_name, :returns => returns) status = stub "process" status.stubs(:exitstatus).returns(exitstatus) @@ -44,6 +44,18 @@ describe Puppet::Type.type(:exec), " when execing" do proc { @execer.refresh }.should raise_error(Puppet::Error) end + + it "should not report a failure if the exit status is specified in a returns array" do + command = "false" + create_resource(command, "", 1, [0,1]) + proc { @execer.refresh }.should_not raise_error(Puppet::Error) + end + + it "should report a failure if the exit status is not specified in a returns array" do + command = "false" + create_resource(command, "", 1, [0,100]) + proc { @execer.refresh }.should raise_error(Puppet::Error) + end it "should log the output on success" do #Puppet::Util::Log.newdestination :console |
