diff options
author | Luke Kanies <luke@madstop.com> | 2005-07-10 01:36:20 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-07-10 01:36:20 +0000 |
commit | c718044c000f3f074fefbe356e9a71f530dfda1b (patch) | |
tree | 2659d77c96bd7154f4c4420b80d41691c4cd4296 /test | |
parent | 3441b82f84ff7dbc15e9a9d3c20da84a7eae8ce5 (diff) | |
download | puppet-c718044c000f3f074fefbe356e9a71f530dfda1b.tar.gz puppet-c718044c000f3f074fefbe356e9a71f530dfda1b.tar.xz puppet-c718044c000f3f074fefbe356e9a71f530dfda1b.zip |
adding the exec stuff
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@338 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-x | test/types/tc_exec.rb | 92 |
1 files changed, 92 insertions, 0 deletions
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 |