diff options
| author | Luke Kanies <luke@madstop.com> | 2007-11-28 15:20:52 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-11-28 15:20:52 -0600 |
| commit | 11ae473e3852adcc382a3efea2329586d2e4bcb3 (patch) | |
| tree | 7a7ff70f7d9f7bc9af0635c56690fb9fc810b9f5 /spec/unit/parser/resource/reference.rb | |
| parent | 8127397e1efafc13975b79eabf7ce951c1e90114 (diff) | |
| download | puppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.tar.gz puppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.tar.xz puppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.zip | |
Theoretically, this patch is to fix #917 (which it does), but
there were enough problems fixing it that I decided something
more drastic needed to be done.
This uses the new Puppet::ResourceReference class to canonize
what a resource reference looks like and how to retrieve resources
via their references. Specifically, it guarantees that resource types
are always capitalized, even when they include '::' in them.
While many files are modified in this commit, the majority of changes are
quite small, and most of the changes are fixing the tests to use
capitalized types.
As we look at consolidating some of our resource types, we could consolidate
the ResourceReference stuff at the same time, but at least the
Puppet::Parser::ResourceReference class subclasses the main Puppet::ResourceReference
class.
Diffstat (limited to 'spec/unit/parser/resource/reference.rb')
| -rwxr-xr-x | spec/unit/parser/resource/reference.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/spec/unit/parser/resource/reference.rb b/spec/unit/parser/resource/reference.rb index 45af3d938..24b70d088 100755 --- a/spec/unit/parser/resource/reference.rb +++ b/spec/unit/parser/resource/reference.rb @@ -15,7 +15,7 @@ describe Puppet::Parser::Resource::Reference do proc { @type.new(:type => "file") }.should raise_error(Puppet::DevError) end - it "should know when it models a builtin type" do + it "should know when it refers to a builtin type" do ref = @type.new(:type => "file", :title => "/tmp/yay") ref.builtin?.should be_true ref.builtintype.should equal(Puppet::Type.type(:file)) @@ -23,13 +23,18 @@ describe Puppet::Parser::Resource::Reference do it "should return a relationship-style resource reference when asked" do ref = @type.new(:type => "file", :title => "/tmp/yay") - ref.to_ref.should == ["file", "/tmp/yay"] + ref.to_ref.should == ["File", "/tmp/yay"] end it "should return a resource reference string when asked" do ref = @type.new(:type => "file", :title => "/tmp/yay") ref.to_s.should == "File[/tmp/yay]" end + + it "should canonize resource references" do + ref = @type.new(:type => "foo::bar", :title => "/tmp/yay") + ref.to_s.should == "Foo::Bar[/tmp/yay]" + end end describe Puppet::Parser::Resource::Reference, " when modeling defined types" do @@ -45,22 +50,21 @@ describe Puppet::Parser::Resource::Reference, " when modeling defined types" do @compile = Puppet::Parser::Compile.new(@node, @parser) end - it "should be able to model definitions" do + it "should be able to find defined types" do ref = @type.new(:type => "mydefine", :title => "/tmp/yay", :scope => @compile.topscope) ref.builtin?.should be_false ref.definedtype.should equal(@definition) end - it "should be able to model classes" do + it "should be able to find classes" do ref = @type.new(:type => "class", :title => "myclass", :scope => @compile.topscope) ref.builtin?.should be_false ref.definedtype.should equal(@class) end - it "should be able to model nodes" do + it "should be able to find nodes" do ref = @type.new(:type => "node", :title => "mynode", :scope => @compile.topscope) ref.builtin?.should be_false ref.definedtype.object_id.should == @nodedef.object_id end end - |
