From c718044c000f3f074fefbe356e9a71f530dfda1b Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Sun, 10 Jul 2005 01:36:20 +0000 Subject: adding the exec stuff git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@338 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/types/tc_exec.rb | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 test/types/tc_exec.rb (limited to 'test') diff --git a/test/types/tc_exec.rb b/test/types/tc_exec.rb new file mode 100755 index 000000000..d188c4487 --- /dev/null +++ b/test/types/tc_exec.rb @@ -0,0 +1,92 @@ +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $puppetbase = "../../../../language/trunk" +end + +require 'puppet' +require 'test/unit' +require 'facter' + +# $Id$ + +class TestExec < Test::Unit::TestCase + def setup + Puppet[:loglevel] = :debug if __FILE__ == $0 + end + + def teardown + Puppet::Type.allclear + end + + def test_execution + command = nil + output = nil + assert_nothing_raised { + command = Puppet::Type::Exec.new( + :command => "/bin/echo" + ) + } + assert_nothing_raised { + command.retrieve + } + assert_nothing_raised { + output = command.sync + } + assert_equal([:executed_command],output) + end + + def test_path_or_qualified + command = nil + output = nil + assert_raise(TypeError) { + command = Puppet::Type::Exec.new( + :command => "echo" + ) + } + Puppet::Type::Exec.clear + assert_nothing_raised { + command = Puppet::Type::Exec.new( + :command => "echo", + :path => "/usr/bin:/bin:/usr/sbin:/sbin" + ) + } + Puppet::Type::Exec.clear + assert_nothing_raised { + command = Puppet::Type::Exec.new( + :command => "/bin/echo" + ) + } + Puppet::Type::Exec.clear + assert_nothing_raised { + command = Puppet::Type::Exec.new( + :command => "/bin/echo", + :path => "/usr/bin:/bin:/usr/sbin:/sbin" + ) + } + end + + def test_nonzero_returns + assert_nothing_raised { + command = Puppet::Type::Exec.new( + :command => "mkdir /this/directory/does/not/exist", + :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :returns => 1 + ) + } + assert_nothing_raised { + command = Puppet::Type::Exec.new( + :command => "touch /etc", + :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :returns => 1 + ) + } + assert_nothing_raised { + command = Puppet::Type::Exec.new( + :command => "thiscommanddoesnotexist", + :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :returns => 127 + ) + } + end +end -- cgit