summaryrefslogtreecommitdiffstats
path: root/spec/unit/node
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-18 11:21:22 -0600
committerLuke Kanies <luke@madstop.com>2007-11-18 11:21:22 -0600
commitc19835ce9f8a5138b30a1a32ca741c996b0916d2 (patch)
tree1a7b05839f013cc8a610f7c9493e206606fab977 /spec/unit/node
parent9290cc89a2206fb5204578f8e91208857a48b147 (diff)
downloadpuppet-c19835ce9f8a5138b30a1a32ca741c996b0916d2.tar.gz
puppet-c19835ce9f8a5138b30a1a32ca741c996b0916d2.tar.xz
puppet-c19835ce9f8a5138b30a1a32ca741c996b0916d2.zip
Fixed most failing tests, but there are still over thirty failing.
At this point, I'm holding the experiment until after the release, so I'm committing this for now and will take it back up after 0.24.0 is out.
Diffstat (limited to 'spec/unit/node')
-rwxr-xr-xspec/unit/node/configuration.rb40
1 files changed, 29 insertions, 11 deletions
diff --git a/spec/unit/node/configuration.rb b/spec/unit/node/configuration.rb
index 7fda4e9a8..44b98dddb 100755
--- a/spec/unit/node/configuration.rb
+++ b/spec/unit/node/configuration.rb
@@ -301,9 +301,9 @@ end
describe Puppet::Node::Configuration, " when functioning as a resource container" do
before do
@config = Puppet::Node::Configuration.new("host")
- @one = stub 'resource1', :ref => "Me[one]", :configuration= => nil
- @two = stub 'resource2', :ref => "Me[two]", :configuration= => nil
- @dupe = stub 'resource3', :ref => "Me[one]", :configuration= => nil
+ @one = stub 'resource1', :ref => "Me[one]", :configuration= => nil, :title => "one", :name => "one"
+ @two = stub 'resource2', :ref => "Me[two]", :configuration= => nil, :title => "two", :name => "two"
+ @dupe = stub 'resource3', :ref => "Me[one]", :configuration= => nil, :title => "one", :name => "one"
end
it "should provide a method to add one or more resources" do
@@ -412,6 +412,25 @@ describe Puppet::Node::Configuration, " when functioning as a resource container
@config.remove_resource(@one)
@config.resource("me", "other").should be_nil
end
+
+ it "should alias resources whose names are not equal to their titles" do
+ resource = stub("resource", :name => "one", :title => "two", :ref => "Me[two]", :configuration= => nil)
+ @config.expects(:alias).with(resource, "one")
+ @config.add_resource resource
+ end
+
+ it "should fail to add resources whose names conflict with an existing resource even when the title does not conflict" do
+ conflict = stub("resource", :name => "one", :ref => "Me[one]", :configuration= => nil)
+ resource = stub("resource", :name => "one", :title => "other", :ref => "Me[other]", :configuration= => nil)
+ @config.expects(:alias).with(resource, "one")
+ @config.add_resource resource
+ end
+
+ it "should not alias components whose names do not match their titles" do
+ comp = Puppet::Type::Component.create :name => "one", :title => "two"
+ @config.expects(:alias).never
+ @config.add_resource comp
+ end
end
module ApplyingConfigurations
@@ -538,19 +557,18 @@ end
describe Puppet::Node::Configuration, " when creating a relationship graph" do
before do
@config = Puppet::Node::Configuration.new("host")
- @compone = Puppet::Type::Component.create :name => "one"
- @comptwo = Puppet::Type::Component.create :name => "two", :require => ["class", "one"]
+ @compone = @config.create_resource :component, :name => "one"
+ @comptwo = @config.create_resource :component, :name => "two", :require => ["class", "one"]
@file = Puppet::Type.type(:file)
- @one = @file.create :path => "/one"
- @two = @file.create :path => "/two"
+ @one = @config.create_resource :file, :path => "/one"
+ @two = @config.create_resource :file, :path => "/two"
@config.add_edge! @compone, @one
@config.add_edge! @comptwo, @two
- @three = @file.create :path => "/three"
- @four = @file.create :path => "/four", :require => ["file", "/three"]
- @five = @file.create :path => "/five"
- @config.add_resource @compone, @comptwo, @one, @two, @three, @four, @five
+ @three = @config.create_resource :file, :path => "/three"
+ @four = @config.create_resource :file, :path => "/four", :require => ["file", "/three"]
+ @five = @config.create_resource :file, :path => "/five"
@relationships = @config.relationship_graph
end