diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-07-11 20:40:53 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-07-11 20:40:53 +0000 |
commit | 1ab45947dab40a99c331a5dc550dc00f54dc3180 (patch) | |
tree | bd1a9bc223a1d44dbb2dfb5a92a894c8e8e0abc1 | |
parent | a6cc3e473fd68bbb7493a81c14fa1a607d88a5a3 (diff) | |
download | puppet-1ab45947dab40a99c331a5dc550dc00f54dc3180.tar.gz puppet-1ab45947dab40a99c331a5dc550dc00f54dc3180.tar.xz puppet-1ab45947dab40a99c331a5dc550dc00f54dc3180.zip |
Adding tests for previous config bugfixes, and updating changelog
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1391 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | CHANGELOG | 4 | ||||
-rw-r--r-- | lib/puppet/config.rb | 39 | ||||
-rwxr-xr-x | test/other/config.rb | 48 |
3 files changed, 77 insertions, 14 deletions
@@ -1,3 +1,7 @@ +0.18.3 + Mostly a bug-fix release; fixed small bugs in the functionality added in + 0.18.2. + 0.18.2 Added templating support. diff --git a/lib/puppet/config.rb b/lib/puppet/config.rb index e4dfe9086..701ee5942 100644 --- a/lib/puppet/config.rb +++ b/lib/puppet/config.rb @@ -19,7 +19,7 @@ class Config return val end else - raise ArgumentError, "Invalid argument %s" % param + raise ArgumentError, "Undefined configuration parameter '%s'" % param end end @@ -104,15 +104,6 @@ class Config @used = [] end - def symbolize(param) - case param - when String: return param.intern - when Symbol: return param - else - raise ArgumentError, "Invalid param type %s" % param.class - end - end - def each @order.each { |name| if @config.include?(name) @@ -170,6 +161,11 @@ class Config end end + def include?(name) + name = name.intern if name.is_a? String + @config.include?(name) + end + # Create a new config object def initialize @order = [] @@ -306,8 +302,8 @@ class Config else raise Puppet::Error, "Invalid value '%s' for %s" % [value.inspect, hash[:name]] end + hash[:parent] = self element = klass.new(hash) - element.parent = self @order << element.name @@ -421,6 +417,15 @@ class Config } end + def symbolize(param) + case param + when String: return param.intern + when Symbol: return param + else + raise ArgumentError, "Invalid param type %s" % param.class + end + end + # Convert our list of objects into a component that can be applied. def to_component transport = self.to_transportable @@ -656,6 +661,10 @@ Generated on #{Time.now}. # Create the new element. Pretty much just sets the name. def initialize(args = {}) + if args.include?(:parent) + self.parent = args[:parent] + args.delete(:parent) + end args.each do |param, value| method = param.to_s + "=" unless self.respond_to? method @@ -834,9 +843,11 @@ Generated on #{Time.now}. def validate(value) return true unless value.is_a? String value.scan(/\$(\w+)/) { |name| - name = name[0] - unless @parent[name] - raise Puppet::Error, "'%s' is unset" % name + name = $1 + unless @parent.include?(name) + raise ArgumentError, + "Configuration parameter '%s' is undefined" % + name end } end diff --git a/test/other/config.rb b/test/other/config.rb index 457010ac0..9f941af4e 100755 --- a/test/other/config.rb +++ b/test/other/config.rb @@ -646,6 +646,54 @@ inttest = 27 assert_equal("yayness", Puppet[:tags], "Tags got changed during config") end + + def test_configs_replace_in_url + config = mkconfig + + config.setdefaults(:mysection, :name => ["yayness", "yay"]) + config.setdefaults(:mysection, :url => ["http://$name/rahness", "yay"]) + + val = nil + assert_nothing_raised { + val = config[:url] + } + + assert_equal("http://yayness/rahness", val, + "Config got messed up") + end + + def test_correct_type_assumptions + config = mkconfig + + file = Puppet::Config::CFile + element = Puppet::Config::CElement + bool = Puppet::Config::CBoolean + + # We have to keep these ordered, unfortunately. + [ + ["/this/is/a/file", file], + ["true", bool], + [true, bool], + ["false", bool], + ["server", element], + ["http://$server/yay", element], + ["$server/yayness", file], + ["$server/yayness.conf", file] + ].each do |ary| + value, type = ary + elem = nil + assert_nothing_raised { + elem = config.newelement( + :name => value, + :default => value, + :section => :yayness + ) + } + + assert_instance_of(type, elem, + "%s got created as wrong type" % value.inspect) + end + end end # $Id$ |