diff options
-rwxr-xr-x | test/puppet/tc_defaults.rb | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/test/puppet/tc_defaults.rb b/test/puppet/tc_defaults.rb new file mode 100755 index 000000000..1fc45a89e --- /dev/null +++ b/test/puppet/tc_defaults.rb @@ -0,0 +1,75 @@ +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $puppetbase = "../../../../language/trunk/" +end + +require 'puppet' +require 'test/unit' + +# $Id$ + +class TestPuppetDefaults < Test::Unit::TestCase + @@dirs = %w{rrddir puppetconf puppetvar logdir statedir certdir} + @@files = %w{logfile checksumfile localcert localkey localpub mastercert masterkey masterpub} + @@booleans = %w{rrdgraph} + def testStringOrParam + [@@dirs,@@files,@@booleans].flatten.each { |param| + assert_nothing_raised { Puppet[param] } + assert_nothing_raised { Puppet[param.intern] } + } + end + + def test_valuesForEach + [@@dirs,@@files,@@booleans].flatten.each { |param| + param = param.intern + assert_nothing_raised { Puppet[param] } + } + end + + def testValuesForEach + [@@dirs,@@files,@@booleans].flatten.each { |param| + assert_nothing_raised { Puppet[param] } + } + end + + def testContained + confdir = Regexp.new(Puppet[:puppetconf]) + vardir = Regexp.new(Puppet[:puppetvar]) + [@@dirs,@@files].flatten.each { |param| + value = Puppet[param] + + unless value =~ confdir or value =~ vardir + assert_nothing_raised { raise "%s is in wrong dir" % value } + end + } + end + + def testArgumentTypes + assert_raise(ArgumentError) { Puppet[["string"]] } + assert_raise(ArgumentError) { Puppet[[:symbol]] } + end + + def testFailOnBogusArgs + [0, "ashoweklj", ";", :thisisafakesymbol].each { |param| + assert_raise(ArgumentError) { Puppet[param] } + } + end + + # we don't want user defaults in /, or root defaults in ~ + def testDefaultsInCorrectRoots + notval = nil + if Process.uid == 0 + notval = Regexp.new(File.expand_path("~")) + else + notval = /^\/var|^\/etc/ + end + [@@dirs,@@files].flatten.each { |param| + value = Puppet[param] + + unless value !~ notval + assert_nothing_raised { raise "%s is in wrong dir" % value } + end + } + end +end |