diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-07-09 20:59:41 +0200 |
|---|---|---|
| committer | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-07-20 20:16:58 +0200 |
| commit | f2c55cc6b4dd6a4db307ea1c031120398fe5fc7e (patch) | |
| tree | f2dce699e649148812e44711e4da3026c174f873 | |
| parent | 8bbd8b4bb295fee7ad99f6137c9851528f1729cc (diff) | |
| download | puppet-f2c55cc6b4dd6a4db307ea1c031120398fe5fc7e.tar.gz puppet-f2c55cc6b4dd6a4db307ea1c031120398fe5fc7e.tar.xz puppet-f2c55cc6b4dd6a4db307ea1c031120398fe5fc7e.zip | |
Fix #2378 and #2391 tests
Fix #2378 - Add some integration tests for catalog filtering
Fix #2391 - Fix up some of the tests
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
| -rwxr-xr-x | spec/integration/defaults.rb | 2 | ||||
| -rwxr-xr-x | spec/integration/indirector/catalog/compiler.rb | 34 | ||||
| -rwxr-xr-x | spec/integration/transaction.rb | 13 | ||||
| -rwxr-xr-x | spec/unit/transaction.rb | 3 |
4 files changed, 50 insertions, 2 deletions
diff --git a/spec/integration/defaults.rb b/spec/integration/defaults.rb index e52eb5352..72b5127e5 100755 --- a/spec/integration/defaults.rb +++ b/spec/integration/defaults.rb @@ -141,7 +141,7 @@ describe "Puppet defaults" do end end - describe "when enabling thing storeconfigs" do + describe "when enabling thin storeconfigs" do before do Puppet::Resource::Catalog.stubs(:cache_class=) Puppet::Node::Facts.stubs(:cache_class=) diff --git a/spec/integration/indirector/catalog/compiler.rb b/spec/integration/indirector/catalog/compiler.rb new file mode 100755 index 000000000..f3ace8d1b --- /dev/null +++ b/spec/integration/indirector/catalog/compiler.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } + +require 'puppet/resource/catalog' + +Puppet::Resource::Catalog.indirection.terminus(:compiler) + +describe Puppet::Resource::Catalog::Compiler do + before do + @catalog = Puppet::Resource::Catalog.new + + @one = Puppet::Resource.new(:file, "/one") + @one.exported = true + + @two = Puppet::Resource.new(:file, "/two") + @catalog.add_resource(@one, @two) + end + + after { Puppet.settings.clear } + + it "should remove exported resources when filtering" do + Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resources.should == [ @two.ref ] + end + + it "should filter out exported resources when finding a catalog" do + request = stub 'request', :name => "mynode" + Puppet::Resource::Catalog.indirection.terminus.stubs(:extract_facts_from_request) + Puppet::Resource::Catalog.indirection.terminus.stubs(:node_from_request) + Puppet::Resource::Catalog.indirection.terminus.stubs(:compile).returns(@catalog) + + Puppet::Resource::Catalog.find(request).resources.should == [ @two.ref ] + end +end diff --git a/spec/integration/transaction.rb b/spec/integration/transaction.rb index c06a43d80..2b8a5d920 100755 --- a/spec/integration/transaction.rb +++ b/spec/integration/transaction.rb @@ -22,4 +22,17 @@ describe Puppet::Transaction do transaction.evaluate end + + it "should not apply exported resources" do + catalog = Puppet::Resource::Catalog.new + resource = Puppet::Type.type(:file).new :path => "/foo/bar", :backup => false + resource.exported = true + catalog.add_resource resource + + transaction = Puppet::Transaction.new(catalog) + + resource.expects(:evaluate).never + + transaction.evaluate + end end diff --git a/spec/unit/transaction.rb b/spec/unit/transaction.rb index 26154e9b9..0e3674775 100755 --- a/spec/unit/transaction.rb +++ b/spec/unit/transaction.rb @@ -55,7 +55,7 @@ describe Puppet::Transaction do describe "when skipping a resource" do before :each do - @resource = stub_everything 'res', :exported? => true + @resource = stub_everything 'res' @catalog = Puppet::Resource::Catalog.new @transaction = Puppet::Transaction.new(@catalog) end @@ -76,6 +76,7 @@ describe Puppet::Transaction do end it "should skip exported resource" do + @resource.stubs(:exported?).returns true @transaction.skip?(@resource).should be_true end end |
