Hi,

This patch resides in the branch fix2378 (sorry for the 
unconventional name, I was reluctant to open a new ticket) in
my github repository:
http://github.com/masterzen/puppet/tree/fix2378

James pushed the commits, but since I failed to
push the correct version on my repository, the first revision
was merged instead of the correct one.

This patch contains the missing pieces (only tests), which have 
already been approved, so it is reasonably safe to apply directly 
without a new review cycle.

Thanks,
Brice

Original Commit msg:
Fix #2378 - Add some integration tests for catalog filtering
Fix #2391 - Fix up some of the tests

Signed-off-by: Brice Figureau <[email protected]>
---
 spec/integration/defaults.rb                    |    2 +-
 spec/integration/indirector/catalog/compiler.rb |   34 +++++++++++++++++++++++
 spec/integration/transaction.rb                 |   13 +++++++++
 spec/unit/transaction.rb                        |    3 +-
 4 files changed, 50 insertions(+), 2 deletions(-)
 create mode 100755 spec/integration/indirector/catalog/compiler.rb

diff --git a/spec/integration/defaults.rb b/spec/integration/defaults.rb
index e52eb53..72b5127 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 0000000..f3ace8d
--- /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 c06a43d..2b8a5d9 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 26154e9..0e36747 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
-- 
1.6.0.2


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to