summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-06-15 19:49:26 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-06-15 19:49:26 +0000
commit6be8b211465ee617e58b96e1622bbf6b6068beb2 (patch)
treebb38847ff648abdfe81739e4b4c6c08720c52de1
parente039f7bcb86c6117a0724c24f33d50aaa67479b1 (diff)
downloadpuppet-6be8b211465ee617e58b96e1622bbf6b6068beb2.tar.gz
puppet-6be8b211465ee617e58b96e1622bbf6b6068beb2.tar.xz
puppet-6be8b211465ee617e58b96e1622bbf6b6068beb2.zip
Modifying the check metaparam so that it just silently ignores metaparams and parameters, since they're uncheckable, and only tries to check properties
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2591 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/metatype/metaparams.rb8
-rwxr-xr-xtest/ral/manager/attributes.rb30
2 files changed, 36 insertions, 2 deletions
diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb
index ede201ff4..7f0a1ef01 100644
--- a/lib/puppet/metatype/metaparams.rb
+++ b/lib/puppet/metatype/metaparams.rb
@@ -80,8 +80,12 @@ class Puppet::Type
next if @resource.propertydefined?(property)
unless propertyklass = @resource.class.validproperty?(property)
- raise Puppet::Error, "%s is not a valid attribute for %s" %
- [property, self.class.name]
+ if @resource.class.validattr?(property)
+ next
+ else
+ raise Puppet::Error, "%s is not a valid attribute for %s" %
+ [property, self.class.name]
+ end
end
next unless propertyklass.checkable?
@resource.newattr(property)
diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb
index 5a5064129..273dc6844 100755
--- a/test/ral/manager/attributes.rb
+++ b/test/ral/manager/attributes.rb
@@ -285,6 +285,36 @@ class TestTypeAttributes < Test::Unit::TestCase
@logs.clear
end
end
+
+ # Make sure the 'check' metaparam just ignores non-properties, rather than failing.
+ def test_check_allows_parameters
+ file = Puppet::Type.type(:file)
+ klass = file.attrclass(:check)
+
+ resource = file.create(:path => tempfile)
+ inst = klass.new(:resource => resource)
+
+ {:property => [:owner, :group], :parameter => [:ignore, :recurse], :metaparam => [:require, :subscribe]}.each do |attrtype, attrs|
+ assert_nothing_raised("Could not set check to a single %s value" % attrtype) do
+ inst.value = attrs[0]
+ end
+
+ if attrtype == :property
+ assert(resource.property(attrs[0]), "Check did not create property instance during single check")
+ end
+ assert_nothing_raised("Could not set check to multiple %s values" % attrtype) do
+ inst.value = attrs
+ end
+ if attrtype == :property
+ assert(resource.property(attrs[1]), "Check did not create property instance during multiple check")
+ end
+ end
+
+ # But make sure actually invalid attributes fail
+ assert_raise(Puppet::Error, ":check did not fail on invalid attribute") do
+ inst.value = :nosuchattr
+ end
+ end
end
# $Id$