summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-16 02:35:23 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-16 02:35:23 +0000
commit86b33867b156f9d80bdccf895f16ec0ac3a8a204 (patch)
tree48759c24523d5d28db46a58e375678db89e6a6aa /test
parent32deb3ff495921769ee0cc6f245e121e59336b1a (diff)
downloadpuppet-86b33867b156f9d80bdccf895f16ec0ac3a8a204.tar.gz
puppet-86b33867b156f9d80bdccf895f16ec0ac3a8a204.tar.xz
puppet-86b33867b156f9d80bdccf895f16ec0ac3a8a204.zip
Adding the ability to have hooks for configuration parameters. This will simplify things like setting the shell path.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1783 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/other/config.rb56
1 files changed, 55 insertions, 1 deletions
diff --git a/test/other/config.rb b/test/other/config.rb
index 09d6abe3b..9eed6b1e0 100755
--- a/test/other/config.rb
+++ b/test/other/config.rb
@@ -1,4 +1,4 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env ruby -I../lib -I../../lib
require 'puppet'
require 'puppet/config'
@@ -797,6 +797,60 @@ inttest = 27
end
+
+ # Test that config parameters correctly call passed-in blocks when the value
+ # is set.
+ def test_paramblocks
+ config = mkconfig()
+
+ testing = nil
+ elem = nil
+ assert_nothing_raised do
+ elem = config.newelement :default => "yay",
+ :name => :blocktest,
+ :section => :test,
+ :hook => proc { |value| testing = value }
+ end
+
+ assert_nothing_raised do
+ assert_equal("yay", elem.value)
+ end
+
+ assert_nothing_raised do
+ elem.value = "yaytest"
+ end
+
+ assert_nothing_raised do
+ assert_equal("yaytest", elem.value)
+ end
+ assert_equal("yaytest", testing)
+
+ assert_nothing_raised do
+ elem.value = "another"
+ end
+
+ assert_nothing_raised do
+ assert_equal("another", elem.value)
+ end
+ assert_equal("another", testing)
+
+ # Now verify it works from setdefault
+ assert_nothing_raised do
+ config.setdefaults :test,
+ :blocktest2 => {
+ :default => "yay",
+ :hook => proc { |v| testing = v }
+ }
+ end
+
+ assert_equal("yay", config[:blocktest2])
+
+ assert_nothing_raised do
+ config[:blocktest2] = "footest"
+ end
+ assert_equal("footest", config[:blocktest2])
+ assert_equal("footest", testing)
+ end
end
# $Id$