diff options
| author | Nigel Kersten <nigelk@google.com> | 2009-08-04 16:38:06 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-08-08 09:37:31 +1000 |
| commit | 79d705faec6b7de2bd644e77e5e4c88e8974f207 (patch) | |
| tree | 3c329afd0ede889777eb6553ee445971771d25c0 /spec/unit | |
| parent | b611c34de2ff9fe35633ca2154bc64c6c793af7d (diff) | |
| download | puppet-79d705faec6b7de2bd644e77e5e4c88e8974f207.tar.gz puppet-79d705faec6b7de2bd644e77e5e4c88e8974f207.tar.xz puppet-79d705faec6b7de2bd644e77e5e4c88e8974f207.zip | |
Fixes #2499. Allows execs to specify an array for the returns parameter
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 |
