diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2011-02-02 16:47:53 -0800 |
|---|---|---|
| committer | Matt Robinson <matt@puppetlabs.com> | 2011-02-02 16:47:53 -0800 |
| commit | d4a468543f1f06d44efdb7e375284b0e65260caf (patch) | |
| tree | 2dff58c6e2af2cd682a1143af8494ee4bdf99964 /spec/unit/resource | |
| parent | 6d9cae2e9ca6a56506f679db02ba9abb30a4df91 (diff) | |
| parent | 876d0503dd93329a73e7f335c10a47330d745293 (diff) | |
| download | puppet-d4a468543f1f06d44efdb7e375284b0e65260caf.tar.gz puppet-d4a468543f1f06d44efdb7e375284b0e65260caf.tar.xz puppet-d4a468543f1f06d44efdb7e375284b0e65260caf.zip | |
Merge branch '2.6.x' into next
* 2.6.x: (46 commits)
Augmentation of tests for prior commit
Fix to fix for #5755 -- backref serialization issues in zaml
Fixed #5564 - Added some more fqdn_rand documentation
Fixed #4968 - Updated list of options turned on by --test in documentation
(#5061) - allow special hostclass/define variables to be evaluated as defaults.
(#6107) Fix an error when auditing a file with empty content
Remove already initialized constant warning from file_spec.rb tests
(#5566) Treat source only File checksums as syntax errors when used with content
Rename variable used in File type validation to be more clear
Remove invalid "timestamp" and "time", and add missing "ctime" File checksum types.
Remove order dependency when specifying source and checksum on File type
Bug #5755 -- ZAML generates extra newline in some hash backreferences.
bug #5681 -- code fix to handle AIX mount output
Bug #5681 -- parse AIX mount command output.
Spec for #5681 to allow parsing of AIX mount output in mount provider
Fixed #6091 - Changed POSIX path matching to allow multiple leading slashes
Bug #6091 -- test leading double-slash in filenames are allowed.
Fixed #6071 - Fixed typo and improved exec path error message
Fixed #6061 - Allowed -1 as password min/max age
Bug #6061 -- verify that negative {min,max}_password_age are accepted.
...
Manually Resolved Conflicts:
lib/puppet/util/zaml.rb
spec/unit/util/zaml_spec.rb
Diffstat (limited to 'spec/unit/resource')
| -rwxr-xr-x | spec/unit/resource/type_spec.rb | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb index a22dc3572..e9c203526 100755 --- a/spec/unit/resource/type_spec.rb +++ b/spec/unit/resource/type_spec.rb @@ -261,6 +261,28 @@ describe Puppet::Resource::Type do @type = Puppet::Resource::Type.new(:hostclass, "foo") end + ['module_name', 'name', 'title'].each do |variable| + it "should allow #{variable} to be evaluated as param default" do + @type.instance_eval { @module_name = "bar" } + var = Puppet::Parser::AST::Variable.new({'value' => variable}) + @type.set_arguments :foo => var + @type.set_resource_parameters(@resource, @scope) + @scope.lookupvar('foo').should == 'bar' + end + end + + # this test is to clarify a crazy edge case + # if you specify these special names as params, the resource + # will override the special variables + it "resource should override defaults" do + @type.set_arguments :name => nil + @resource[:name] = 'foobar' + var = Puppet::Parser::AST::Variable.new({'value' => 'name'}) + @type.set_arguments :foo => var + @type.set_resource_parameters(@resource, @scope) + @scope.lookupvar('foo').should == 'foobar' + end + it "should set each of the resource's parameters as variables in the scope" do @type.set_arguments :foo => nil, :boo => nil @resource[:foo] = "bar" @@ -496,7 +518,7 @@ describe Puppet::Resource::Type do it "should evaluate the parent's resource" do @type.parent_type(@scope) - + @type.evaluate_code(@resource) @scope.class_scope(@parent_type).should_not be_nil @@ -504,7 +526,7 @@ describe Puppet::Resource::Type do it "should not evaluate the parent's resource if it has already been evaluated" do @parent_resource.evaluate - + @type.parent_type(@scope) @parent_resource.expects(:evaluate).never @@ -544,7 +566,7 @@ describe Puppet::Resource::Type do it "should not evaluate the parent's resource if it has already been evaluated" do @parent_resource.evaluate - + @type.parent_type(@scope) @parent_resource.expects(:evaluate).never @@ -574,7 +596,7 @@ describe Puppet::Resource::Type do @code = Puppet::Resource::TypeCollection.new("env") @code.add @top @code.add @middle - + @node.environment.stubs(:known_resource_types).returns(@code) end @@ -600,12 +622,36 @@ describe Puppet::Resource::Type do @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource) end + it "should add specified parameters to the resource" do + @top.ensure_in_catalog(@scope, {'one'=>'1', 'two'=>'2'}) + @compiler.catalog.resource(:class, "top")['one'].should == '1' + @compiler.catalog.resource(:class, "top")['two'].should == '2' + end + + it "should not require params for a param class" do + @top.ensure_in_catalog(@scope, {}) + @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource) + end + it "should evaluate the parent class if one exists" do @middle.ensure_in_catalog(@scope) @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource) end + it "should evaluate the parent class if one exists" do + @middle.ensure_in_catalog(@scope, {}) + + @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource) + end + + it "should fail if you try to create duplicate class resources" do + othertop = Puppet::Parser::Resource.new(:class, 'top',:source => @source, :scope => @scope ) + # add the same class resource to the catalog + @compiler.catalog.add_resource(othertop) + lambda { @top.ensure_in_catalog(@scope, {}) }.should raise_error(Puppet::Resource::Catalog::DuplicateResourceError) + end + it "should fail to evaluate if a parent class is defined but cannot be found" do othertop = Puppet::Resource::Type.new :hostclass, "something", :parent => "yay" @code.add othertop |
