summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
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$