summaryrefslogtreecommitdiffstats
path: root/spec/unit/node
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-02-23 19:06:29 -0500
committerLuke Kanies <luke@madstop.com>2008-02-23 19:06:29 -0500
commitff9705914570158d1bad3073728a2e94ca4a0060 (patch)
treef005f1ba130f66913f35a80c0f7d1eccd9f0bab5 /spec/unit/node
parent9b6e5013e387998936979d7a372acde3af65cf61 (diff)
downloadpuppet-ff9705914570158d1bad3073728a2e94ca4a0060.tar.gz
puppet-ff9705914570158d1bad3073728a2e94ca4a0060.tar.xz
puppet-ff9705914570158d1bad3073728a2e94ca4a0060.zip
Somewhat refactored fileserving so that it no longer caches
any objects, nor does it use Puppet's RAL resources. In the process, I fixed #894 (you can now copy links) and refactored other classes as necessary. Mostly it was fixing tests. This is a squashed commit of a temporary branch, fwiw, and it also includes any fixes to the tests that were necessary to get all tests passing again.
Diffstat (limited to 'spec/unit/node')
-rwxr-xr-xspec/unit/node/catalog.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/unit/node/catalog.rb b/spec/unit/node/catalog.rb
index ecbd20487..b1bf5abaa 100755
--- a/spec/unit/node/catalog.rb
+++ b/spec/unit/node/catalog.rb
@@ -460,6 +460,12 @@ describe Puppet::Node::Catalog, " when functioning as a resource container" do
proc { @catalog.alias @one, "one" }.should_not raise_error
end
+ it "should be able to look resources up by their aliases" do
+ @catalog.add_resource @one
+ @catalog.alias @one, "two"
+ @catalog.resource(:me, "two").should equal(@one)
+ end
+
it "should remove resource aliases when the target resource is removed" do
@catalog.add_resource @one
@catalog.alias(@one, "other")
@@ -468,12 +474,21 @@ describe Puppet::Node::Catalog, " when functioning as a resource container" do
@catalog.resource("me", "other").should be_nil
end
- it "should add an alias for the namevar when the title and name differ" do
- @one.stubs(:name).returns "other"
+ it "should add an alias for the namevar when the title and name differ on isomorphic resource types" do
resource = Puppet::Type.type(:file).create :path => "/something", :title => "other", :content => "blah"
@catalog.add_resource(resource)
@catalog.resource(:file, "other").should equal(resource)
- @catalog.resource(:file, "/something").should equal(resource)
+ @catalog.resource(:file, "/something").ref.should == resource.ref
+ end
+
+ it "should not add an alias for the namevar when the title and name differ on non-isomorphic resource types" do
+ resource = Puppet::Type.type(:exec).create :command => "/bin/true", :title => "other"
+ @catalog.add_resource(resource)
+ @catalog.resource(:exec, resource.title).should equal(resource)
+ # We can't use .should here, because the resources respond to that method.
+ if @catalog.resource(:exec, resource.name)
+ raise "Aliased non-isomorphic resource"
+ end
end
after do
@@ -601,6 +616,7 @@ end
describe Puppet::Node::Catalog, " when creating a relationship graph" do
before do
+ Puppet::Type.type(:component)
@catalog = Puppet::Node::Catalog.new("host")
@compone = Puppet::Type::Component.create :name => "one"
@comptwo = Puppet::Type::Component.create :name => "two", :require => ["class", "one"]