summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-19 01:36:48 -0600
committerLuke Kanies <luke@madstop.com>2007-11-19 01:36:48 -0600
commit2b14f627aca1d5be69cf6606044df4d6e67f6eba (patch)
treea20db3a608af483f598f482e743868413da8fd8f /spec
parent9cf477b6cc771eab7bd29d18c49128571e877987 (diff)
downloadpuppet-2b14f627aca1d5be69cf6606044df4d6e67f6eba.tar.gz
puppet-2b14f627aca1d5be69cf6606044df4d6e67f6eba.tar.xz
puppet-2b14f627aca1d5be69cf6606044df4d6e67f6eba.zip
Reverting the changes I'd made toward removing the global
resources. These are commits: c19835ce9f8a5138b30a1a32ca741c996b0916d2 9290cc89a2206fb5204578f8e91208857a48b147 ffb4c2dbc7314b364d25e4f7be599ef05b767b44
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/network/client/master.rb113
-rwxr-xr-xspec/unit/node/configuration.rb41
2 files changed, 12 insertions, 142 deletions
diff --git a/spec/unit/network/client/master.rb b/spec/unit/network/client/master.rb
index fda729cae..dca923994 100755
--- a/spec/unit/network/client/master.rb
+++ b/spec/unit/network/client/master.rb
@@ -72,7 +72,6 @@ describe Puppet::Network::Client::Master, " when retrieving the configuration" d
@client.stubs(:fresh?).with(@facts).returns true
@client.stubs(:use_cached_config).returns(true)
@client.class.stubs(:facts).returns(@facts)
- @client.stubs(:add_default_resources)
@client.getconfig
end
@@ -98,7 +97,6 @@ describe Puppet::Network::Client::Master, " when retrieving the configuration" d
config.stubs(:to_configuration).returns(config)
config.stubs(:host_config=)
config.stubs(:from_cache).returns(true)
- @client.stubs(:add_default_resources)
@client.getconfig
end
@@ -129,7 +127,6 @@ describe Puppet::Network::Client::Master, " when retrieving the configuration" d
config.stubs(:to_configuration).returns(config)
config.stubs(:host_config=)
config.stubs(:from_cache).returns(true)
- @client.stubs(:add_default_resources)
@client.getconfig
end
@@ -148,9 +145,9 @@ describe Puppet::Network::Client::Master, " when retrieving the configuration" d
yamlconfig.stubs(:classes)
yamlconfig.expects(:to_configuration).returns(config)
+
config.stubs(:host_config=)
config.stubs(:from_cache).returns(true)
- @client.stubs(:add_default_resources)
@client.getconfig
end
@@ -213,7 +210,6 @@ describe Puppet::Network::Client::Master, " when retrieving the configuration" d
yamlconfig.expects(:to_configuration).returns(config)
config.stubs(:host_config=)
- @client.stubs(:add_default_resources)
config.expects(:from_cache).returns(false)
@@ -240,31 +236,6 @@ describe Puppet::Network::Client::Master, " when retrieving the configuration" d
config.stubs(:from_cache).returns(true)
config.expects(:host_config=).with(true)
- @client.stubs(:add_default_resources)
-
- @client.getconfig
- end
-
- it "should add the default resources to the configuration" do
- @client.stubs(:dostorage)
- @client.class.stubs(:facts).returns(@facts)
- @master.stubs(:getconfig).returns("myconfig")
-
- yamlconfig = mock 'yaml config'
- YAML.stubs(:load).returns(yamlconfig)
-
- @client.stubs(:setclasses)
-
- config = mock 'config'
-
- yamlconfig.stubs(:classes)
- yamlconfig.stubs(:to_configuration).returns(config)
-
- config.stubs(:from_cache).returns(true)
-
- config.stubs(:host_config=).with(true)
-
- @client.expects(:add_default_resources).with(config)
@client.getconfig
end
@@ -336,7 +307,6 @@ describe Puppet::Network::Client::Master, " when using the cached configuration"
config.expects(:to_configuration).returns(ral_config)
@client.stubs(:retrievecache).returns("whatever")
- @client.stubs(:add_default_resources)
Puppet::Network::Client::Master.publicize_methods :use_cached_config do
@client.use_cached_config().should be_true
end
@@ -352,7 +322,6 @@ describe Puppet::Network::Client::Master, " when using the cached configuration"
config.expects(:to_configuration).returns(ral_config)
@client.stubs(:retrievecache).returns("whatever")
- @client.stubs(:add_default_resources)
Puppet::Network::Client::Master.publicize_methods :use_cached_config do
@client.use_cached_config()
end
@@ -370,7 +339,6 @@ describe Puppet::Network::Client::Master, " when using the cached configuration"
config.expects(:to_configuration).returns(ral_config)
@client.stubs(:retrievecache).returns("whatever")
- @client.stubs(:add_default_resources)
Puppet::Network::Client::Master.publicize_methods :use_cached_config do
@client.use_cached_config()
end
@@ -388,89 +356,10 @@ describe Puppet::Network::Client::Master, " when using the cached configuration"
config.expects(:to_configuration).returns(ral_config)
@client.stubs(:retrievecache).returns("whatever")
- @client.stubs(:add_default_resources)
Puppet::Network::Client::Master.publicize_methods :use_cached_config do
@client.use_cached_config()
end
@client.configuration.should equal(ral_config)
end
-
- it "should add the default resources to the configuration" do
- config = mock 'config'
- YAML.stubs(:load).returns(config)
-
- ral_config = mock 'ral config'
- ral_config.expects(:from_cache=).with(true)
- ral_config.stubs(:host_config=)
- config.stubs(:to_configuration).returns(ral_config)
-
- @client.stubs(:retrievecache).returns("whatever")
- @client.expects(:add_default_resources).with(ral_config)
- Puppet::Network::Client::Master.publicize_methods :use_cached_config do
- @client.use_cached_config()
- end
- end
-end
-
-describe Puppet::Network::Client::Master, " when adding default resources" do
- before do
- @master = mock 'master'
- @client = Puppet::Network::Client.master.new(
- :Master => @master
- )
- @facts = {"one" => "two", "three" => "four"}
- end
-
- it "should add the default schedules" do
- config = mock 'config'
- one = stub 'one', :title => "one"
- two = stub 'two', :title => "two"
- Puppet::Type.type(:schedule).expects(:create_default_resources).with().returns([one, two])
- config.expects(:add_resource).with(one)
- config.expects(:add_resource).with(two)
- config.stubs(:resource).returns(false)
- Puppet::Type.type(:filebucket).stubs(:create_default_resources).returns([])
- Puppet::Network::Client::Master.publicize_methods :add_default_resources do
- @client.add_default_resources(config)
- end
- end
-
- it "should add the default filebucket" do
- config = mock 'config'
- Puppet::Type.type(:schedule).stubs(:create_default_resources).returns([])
- one = stub 'one', :title => "one"
- two = stub 'two', :title => "two"
- Puppet::Type.type(:filebucket).expects(:create_default_resources).with().returns([one, two])
- config.expects(:add_resource).with(one)
- config.expects(:add_resource).with(two)
- config.stubs(:resource).returns(false)
- Puppet::Network::Client::Master.publicize_methods :add_default_resources do
- @client.add_default_resources(config)
- end
- end
-
- it "should only add a default filebucket if no similarly named bucket already exists" do
- config = mock 'config'
- Puppet::Type.type(:schedule).stubs(:create_default_resources).returns([])
- one = stub 'one', :title => "one"
- Puppet::Type.type(:filebucket).expects(:create_default_resources).with().returns([one])
- config.expects(:resource).with(:filebucket, "one").returns(true)
- config.expects(:add_resource).with(one).never
- Puppet::Network::Client::Master.publicize_methods :add_default_resources do
- @client.add_default_resources(config)
- end
- end
-
- it "should only add default schedules if no similarly named schedule already exists" do
- config = mock 'config'
- one = stub 'one', :title => "one"
- Puppet::Type.type(:schedule).stubs(:create_default_resources).returns([one])
- Puppet::Type.type(:filebucket).stubs(:create_default_resources).with().returns([])
- config.expects(:resource).with(:schedule, "one").returns(true)
- config.expects(:add_resource).with(one).never
- Puppet::Network::Client::Master.publicize_methods :add_default_resources do
- @client.add_default_resources(config)
- end
- end
end
diff --git a/spec/unit/node/configuration.rb b/spec/unit/node/configuration.rb
index 44b98dddb..5780d4fbb 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, :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"
+ @one = stub 'resource1', :ref => "Me[one]", :configuration= => nil
+ @two = stub 'resource2', :ref => "Me[two]", :configuration= => nil
+ @dupe = stub 'resource3', :ref => "Me[one]", :configuration= => nil
end
it "should provide a method to add one or more resources" do
@@ -412,25 +412,6 @@ 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
@@ -557,18 +538,18 @@ end
describe Puppet::Node::Configuration, " when creating a relationship graph" do
before do
@config = Puppet::Node::Configuration.new("host")
- @compone = @config.create_resource :component, :name => "one"
- @comptwo = @config.create_resource :component, :name => "two", :require => ["class", "one"]
-
+ @compone = Puppet::Type::Component.create :name => "one"
+ @comptwo = Puppet::Type::Component.create :name => "two", :require => ["class", "one"]
@file = Puppet::Type.type(:file)
- @one = @config.create_resource :file, :path => "/one"
- @two = @config.create_resource :file, :path => "/two"
+ @one = @file.create :path => "/one"
+ @two = @file.create :path => "/two"
@config.add_edge! @compone, @one
@config.add_edge! @comptwo, @two
- @three = @config.create_resource :file, :path => "/three"
- @four = @config.create_resource :file, :path => "/four", :require => ["file", "/three"]
- @five = @config.create_resource :file, :path => "/five"
+ @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
@relationships = @config.relationship_graph
end