diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-08-10 20:08:18 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-08-13 08:10:00 +1000 |
| commit | d86bc889390e56aa007b0099f9f407d4be98c876 (patch) | |
| tree | 49134021bf7041fc92b928d9106d0f4c0e716ca5 | |
| parent | aad3b76da045d2fd845866fb6e8a7c9866307cd8 (diff) | |
| download | puppet-d86bc889390e56aa007b0099f9f407d4be98c876.tar.gz puppet-d86bc889390e56aa007b0099f9f407d4be98c876.tar.xz puppet-d86bc889390e56aa007b0099f9f407d4be98c876.zip | |
Fix #2507 - Add missing integration tests
Some of the integration tests were either missing or not complete,
especially tests about exported non virtual resources or virtual
and exported resources.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
| -rwxr-xr-x | spec/integration/indirector/catalog/compiler.rb | 39 | ||||
| -rwxr-xr-x | spec/integration/transaction.rb | 30 |
2 files changed, 65 insertions, 4 deletions
diff --git a/spec/integration/indirector/catalog/compiler.rb b/spec/integration/indirector/catalog/compiler.rb index 211b7c237..16102cafe 100755 --- a/spec/integration/indirector/catalog/compiler.rb +++ b/spec/integration/indirector/catalog/compiler.rb @@ -11,7 +11,6 @@ describe Puppet::Resource::Catalog::Compiler do @catalog = Puppet::Resource::Catalog.new @one = Puppet::Resource.new(:file, "/one") - @one.virtual = true @two = Puppet::Resource.new(:file, "/two") @catalog.add_resource(@one, @two) @@ -19,11 +18,45 @@ describe Puppet::Resource::Catalog::Compiler do after { Puppet.settings.clear } - it "should remove exported resources when filtering" do + it "should remove virtual resources when filtering" do + @one.virtual = true Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resources.should == [ @two.ref ] end - it "should filter out exported resources when finding a catalog" do + it "should not remove exported resources when filtering" do + @one.exported = true + Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resources.sort.should == [ @one.ref, @two.ref ] + end + + it "should remove virtual exported resources when filtering" do + @one.exported = true + @one.virtual = true + Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resources.should == [ @two.ref ] + end + + it "should filter out virtual resources when finding a catalog" do + @one.virtual = true + 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 + + it "should not filter out exported resources when finding a catalog" do + @one.exported = true + 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.sort.should == [ @one.ref, @two.ref ] + end + + it "should filter out virtual exported resources when finding a catalog" do + @one.exported = true + @one.virtual = true request = stub 'request', :name => "mynode" Puppet::Resource::Catalog.indirection.terminus.stubs(:extract_facts_from_request) Puppet::Resource::Catalog.indirection.terminus.stubs(:node_from_request) diff --git a/spec/integration/transaction.rb b/spec/integration/transaction.rb index 2b8a5d920..7ab852bd2 100755 --- a/spec/integration/transaction.rb +++ b/spec/integration/transaction.rb @@ -23,10 +23,37 @@ describe Puppet::Transaction do transaction.evaluate end - it "should not apply exported resources" do + it "should not apply virtual resources" do + catalog = Puppet::Resource::Catalog.new + resource = Puppet::Type.type(:file).new :path => "/foo/bar", :backup => false + resource.virtual = true + catalog.add_resource resource + + transaction = Puppet::Transaction.new(catalog) + + resource.expects(:evaluate).never + + transaction.evaluate + end + + it "should 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 + + it "should not apply virtual exported resources" do catalog = Puppet::Resource::Catalog.new resource = Puppet::Type.type(:file).new :path => "/foo/bar", :backup => false resource.exported = true + resource.virtual = true catalog.add_resource resource transaction = Puppet::Transaction.new(catalog) @@ -35,4 +62,5 @@ describe Puppet::Transaction do transaction.evaluate end + end |
