summaryrefslogtreecommitdiffstats
path: root/test/puppet/defaults.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-22 22:27:20 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-22 22:27:20 +0000
commitf7328804d00d8a82d7ab3a955ff579ff956ef3d0 (patch)
tree7a6d5119dea6a6309675120fd99f5cc023ad644a /test/puppet/defaults.rb
parent8fe558cca075ab85619a73f4a80408de58810ef7 (diff)
downloadpuppet-f7328804d00d8a82d7ab3a955ff579ff956ef3d0.tar.gz
puppet-f7328804d00d8a82d7ab3a955ff579ff956ef3d0.tar.xz
puppet-f7328804d00d8a82d7ab3a955ff579ff956ef3d0.zip
Getting rid of the tc_ prefix to test cases
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@724 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/puppet/defaults.rb')
-rwxr-xr-xtest/puppet/defaults.rb100
1 files changed, 100 insertions, 0 deletions
diff --git a/test/puppet/defaults.rb b/test/puppet/defaults.rb
new file mode 100755
index 000000000..e1d0124d2
--- /dev/null
+++ b/test/puppet/defaults.rb
@@ -0,0 +1,100 @@
+if __FILE__ == $0
+ $:.unshift '..'
+ $:.unshift '../../lib'
+ $puppetbase = ".."
+end
+
+require 'puppet'
+require 'test/unit'
+
+# $Id$
+
+class TestPuppetDefaults < Test::Unit::TestCase
+ @@dirs = %w{rrddir puppetconf puppetvar logdir statedir}
+ @@files = %w{logfile checksumfile manifest masterlog}
+ @@normals = %w{puppetport masterport server}
+ @@booleans = %w{rrdgraph noop}
+
+ def testVersion
+ assert( Puppet.version =~ /^[0-9]+(\.[0-9]+)*$/ )
+ end
+
+ 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
+
+ if __FILE__ == $0
+ def disabled_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: %s" %
+ [param,value] }
+ end
+ }
+ 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: %s" %
+ [param,value] }
+ end
+ }
+ end
+
+ def test_settingdefaults
+ testvals = {
+ :fakeparam => [:puppetconf, "yaytest"],
+ :anotherparam => proc { File.join(Puppet[:puppetvar], "goodtest") },
+ :string => "a yay string",
+ :boolean => true
+ }
+
+ testvals.each { |param, default|
+ assert_nothing_raised {
+ Puppet.setdefault(param,default)
+ }
+ }
+ end
+end