From 79d705faec6b7de2bd644e77e5e4c88e8974f207 Mon Sep 17 00:00:00 2001 From: Nigel Kersten Date: Tue, 4 Aug 2009 16:38:06 -0700 Subject: Fixes #2499. Allows execs to specify an array for the returns parameter --- spec/unit/type/exec.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'spec/unit') 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 -- cgit