diff options
author | Luke Kanies <luke@madstop.com> | 2007-11-18 23:33:34 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-11-18 23:33:34 -0600 |
commit | 26e9bd5637a8b002b9bc214793f95cbde4932bb2 (patch) | |
tree | 6716cdc1c5b9d4d564b344fc10d901bac89b9f76 | |
parent | 8838e9bb7cf5d0445a8ddbce0bd983551a191659 (diff) | |
parent | 445c29c4b108e04b3f077316b36ba50284a7d5d5 (diff) | |
download | puppet-26e9bd5637a8b002b9bc214793f95cbde4932bb2.tar.gz puppet-26e9bd5637a8b002b9bc214793f95cbde4932bb2.tar.xz puppet-26e9bd5637a8b002b9bc214793f95cbde4932bb2.zip |
Merge commit 'davids-bugfixes/rest/tests-for-872'
-rwxr-xr-x | lib/puppet/type/pfile/content.rb | 6 | ||||
-rwxr-xr-x | spec/unit/ral/types/file.rb | 32 |
2 files changed, 38 insertions, 0 deletions
diff --git a/lib/puppet/type/pfile/content.rb b/lib/puppet/type/pfile/content.rb index 11458ef18..6dcda0aa6 100755 --- a/lib/puppet/type/pfile/content.rb +++ b/lib/puppet/type/pfile/content.rb @@ -33,7 +33,13 @@ module Puppet end # Override this method to provide diffs if asked for. + # Also, fix #872: when content is used, and replace is true, the file + # should be insync when it exists def insync?(is) + if ! @resource.replace? and File.exists?(@resource[:path]) + return true + end + result = super if ! result and Puppet[:show_diff] and File.exists?(@resource[:path]) string_file_diff(@resource[:path], self.should) diff --git a/spec/unit/ral/types/file.rb b/spec/unit/ral/types/file.rb new file mode 100755 index 000000000..823d643b0 --- /dev/null +++ b/spec/unit/ral/types/file.rb @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' +require 'tempfile' + +describe Puppet::type(:file), " when used with replace=>false and content" do + + before do + @path = Tempfile.new("puppetspec") + @path.close!() + @path = @path.path + @file = Puppet::type(:file).create( { :name => @path, :content => "foo", :replace => :false } ) + end + + after do + end + + it "should be insync if the file exists and the content is different" do + File.open(@path, "w") do |f| f.puts "bar" end + @file.property(:content).insync?("bar").should be_true + end + + it "should be insync if the file exists and the content is right" do + File.open(@path, "w") do |f| f.puts "foo" end + @file.property(:content).insync?("foo").should be_true + end + + it "should not be insync if the file doesnot exist" do + @file.property(:content).insync?(:nil).should be_false + end + +end |