diff options
| author | Luke Kanies <luke@madstop.com> | 2009-02-06 19:11:54 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2009-02-06 19:11:54 -0600 |
| commit | 916abc2e68a9b0a095c5783854a4b0a4819ddf2c (patch) | |
| tree | 74a966dbdd93b0f4a78b63a2e042d8f6a557276d /spec/unit | |
| parent | 53357884111d3499746b292f99948d5eb3c83415 (diff) | |
| download | puppet-916abc2e68a9b0a095c5783854a4b0a4819ddf2c.tar.gz puppet-916abc2e68a9b0a095c5783854a4b0a4819ddf2c.tar.xz puppet-916abc2e68a9b0a095c5783854a4b0a4819ddf2c.zip | |
Changing how the Configurer interacts with the cache
This changes the hooks provided via the Indirector Request
for determining how the cache is used. These hooks are only
used by the Configurer class. They're messy, but I can't
come up with a better design, and they're at least sufficient.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/configurer.rb | 18 | ||||
| -rwxr-xr-x | spec/unit/indirector/indirection.rb | 21 | ||||
| -rwxr-xr-x | spec/unit/indirector/request.rb | 16 |
3 files changed, 39 insertions, 16 deletions
diff --git a/spec/unit/configurer.rb b/spec/unit/configurer.rb index 92478eea8..f74cf99f0 100755 --- a/spec/unit/configurer.rb +++ b/spec/unit/configurer.rb @@ -85,35 +85,35 @@ describe Puppet::Configurer, "when retrieving a catalog" do end it "should default to returning a catalog retrieved directly from the server, skipping the cache" do - Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:use_cache] == false }.returns @catalog + Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog @agent.retrieve_catalog.should == @catalog end it "should return the cached catalog when no catalog can be retrieved from the server" do - Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:use_cache] == false }.returns nil - Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:use_cache] == true }.returns @catalog + Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns nil + Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog @agent.retrieve_catalog.should == @catalog end it "should not look in the cache for a catalog if one is returned from the server" do - Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:use_cache] == false }.returns @catalog - Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:use_cache] == true }.never + Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog + Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.never @agent.retrieve_catalog.should == @catalog end it "should return the cached catalog when retrieving the remote catalog throws an exception" do - Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:use_cache] == false }.raises "eh" - Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:use_cache] == true }.returns @catalog + Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.raises "eh" + Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog @agent.retrieve_catalog.should == @catalog end it "should return nil if no cached catalog is available and no catalog can be retrieved from the server" do - Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:use_cache] == false }.returns nil - Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:use_cache] == true }.returns nil + Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns nil + Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns nil @agent.retrieve_catalog.should be_nil end diff --git a/spec/unit/indirector/indirection.rb b/spec/unit/indirector/indirection.rb index 84b4e0e24..dc4157fd2 100755 --- a/spec/unit/indirector/indirection.rb +++ b/spec/unit/indirector/indirection.rb @@ -6,7 +6,7 @@ require 'puppet/indirector/indirection' describe "Indirection Delegator", :shared => true do it "should create a request object with the appropriate method name and all of the passed arguments" do - request = stub 'request', :node => nil + request = Puppet::Indirector::Request.new(:indirection, :find, "me") @indirection.expects(:request).with(@method, "mystuff", :one => :two).returns request @@ -22,7 +22,7 @@ describe "Indirection Delegator", :shared => true do end end - request = stub 'request', :key => "me", :options => {} + request = Puppet::Indirector::Request.new(:indirection, :find, "me") @indirection.stubs(:request).returns request @@ -261,8 +261,23 @@ describe Puppet::Indirector::Indirection do it "should not look in the cache if the request specifies not to use the cache" do @terminus.expects(:find).returns @instance @cache.expects(:find).never + @cache.stubs(:save) + + @indirection.find("/my/key", :ignore_cache => true) + end + + it "should still save to the cache even if the cache is being ignored during readin" do + @terminus.expects(:find).returns @instance + @cache.expects(:save) + + @indirection.find("/my/key", :ignore_cache => true) + end + + it "should only look in the cache if the request specifies not to use the terminus" do + @terminus.expects(:find).never + @cache.expects(:find) - @indirection.find("/my/key", :use_cache => false) + @indirection.find("/my/key", :ignore_terminus => true) end it "should use a request to look in the cache for cached objects" do diff --git a/spec/unit/indirector/request.rb b/spec/unit/indirector/request.rb index 5203280d8..12e196f77 100755 --- a/spec/unit/indirector/request.rb +++ b/spec/unit/indirector/request.rb @@ -127,12 +127,20 @@ describe Puppet::Indirector::Request do end end - it "should allow indication that it should not use a cached instance" do - Puppet::Indirector::Request.new(:ind, :method, :key, :use_cache => false).should_not be_use_cache + it "should allow indication that it should not read a cached instance" do + Puppet::Indirector::Request.new(:ind, :method, :key, :ignore_cache => true).should be_ignore_cache end - it "should default to using cached instances" do - Puppet::Indirector::Request.new(:ind, :method, :key).should be_use_cache + it "should default to not ignoring the cache" do + Puppet::Indirector::Request.new(:ind, :method, :key).should_not be_ignore_cache + end + + it "should allow indication that it should not not read an instance from the terminus" do + Puppet::Indirector::Request.new(:ind, :method, :key, :ignore_terminus => true).should be_ignore_terminus + end + + it "should default to not ignoring the terminus" do + Puppet::Indirector::Request.new(:ind, :method, :key).should_not be_ignore_terminus end end |
