diff options
Diffstat (limited to 'spec/unit')
-rwxr-xr-x | spec/unit/transaction.rb | 2 | ||||
-rwxr-xr-x | spec/unit/type/file.rb | 46 |
2 files changed, 31 insertions, 17 deletions
diff --git a/spec/unit/transaction.rb b/spec/unit/transaction.rb index 86ee02ce5..2589f7fc9 100755 --- a/spec/unit/transaction.rb +++ b/spec/unit/transaction.rb @@ -48,7 +48,7 @@ describe Puppet::Transaction do resource.expects(:finish).never - @transaction.generate_additional_resources(generator, :generate) + @transaction.generate_additional_resources(generator, :generate).should be_empty end end end diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb index 1c6976440..582cc1f81 100755 --- a/spec/unit/type/file.rb +++ b/spec/unit/type/file.rb @@ -467,22 +467,6 @@ describe Puppet::Type.type(:file) do @file.recurse_remote("first" => @resource) end - describe "and purging is enabled" do - before do - @file[:purge] = true - end - - it "should configure each file not on the remote system to be removed" do - @file.stubs(:perform_recursion).returns [@second] - - @resource.expects(:[]=).with(:ensure, :absent) - - @file.expects(:newchild).returns stub('secondfile', :[]= => nil, :parameter => @parameter) - - @file.recurse_remote("first" => @resource) - end - end - describe "and multiple sources are provided" do describe "and :sourceselect is set to :first" do it "should create file instances for the results for the first source to return any values" do @@ -608,6 +592,36 @@ describe Puppet::Type.type(:file) do @file.recurse.should == [one, two, three] end + describe "and purging is enabled" do + before do + @file[:purge] = true + end + + it "should configure each file to be removed" do + local = stub 'local' + local.stubs(:[]).with(:source).returns nil # Thus, a local file + local.stubs(:[]).with(:path).returns "foo" + @file.expects(:recurse_local).returns("local" => local) + local.expects(:[]=).with(:ensure, :absent) + + @file.recurse + end + + it "should not remove files that exist in the remote repository" do + @file["source"] = "/my/file" + @file.expects(:recurse_local).returns({}) + + remote = stub 'remote' + remote.stubs(:[]).with(:source).returns "/whatever" # Thus, a remote file + remote.stubs(:[]).with(:path).returns "foo" + + @file.expects(:recurse_remote).with { |hash| hash["remote"] = remote } + remote.expects(:[]=).with(:ensure, :absent).never + + @file.recurse + end + end + describe "and making a new child resource" do it "should not copy the parent resource's parent" do Puppet::Type.type(:file).expects(:new).with { |options| ! options.include?(:parent) } |