summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-07-09 20:59:41 +0200
committerBrice Figureau <brice-puppet@daysofwonder.com>2009-07-20 20:16:58 +0200
commitf2c55cc6b4dd6a4db307ea1c031120398fe5fc7e (patch)
treef2dce699e649148812e44711e4da3026c174f873
parent8bbd8b4bb295fee7ad99f6137c9851528f1729cc (diff)
downloadpuppet-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-xspec/integration/defaults.rb2
-rwxr-xr-xspec/integration/indirector/catalog/compiler.rb34
-rwxr-xr-xspec/integration/transaction.rb13
-rwxr-xr-xspec/unit/transaction.rb3
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