[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

James Turnbull james at lovedthanlost.net
Fri Jan 23 14:21:56 UTC 2009


The following commit has been merged in the master branch:
commit 18fe5c3ac2ad4c42afd30ba2effad28607fe746d
Author: Luke Kanies <luke at madstop.com>
Date:   Sun Dec 7 18:04:14 2008 -0600

    Fixing #1750 again - All of the properties and now :ensure check replace?
    
    Signed-off-by: Luke Kanies <luke at madstop.com>

diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb
index 3a1a824..175b821 100755
--- a/lib/puppet/type/file/ensure.rb
+++ b/lib/puppet/type/file/ensure.rb
@@ -137,6 +137,10 @@ module Puppet
         # We have to treat :present specially, because it works with any
         # type of file.
         def insync?(currentvalue)
+            unless currentvalue == :absent or resource.replace?
+                return true
+            end
+
             if self.should == :present
                 if currentvalue.nil? or currentvalue == :absent
                     return false
diff --git a/spec/unit/type/file/ensure.rb b/spec/unit/type/file/ensure.rb
new file mode 100755
index 0000000..b336c7c
--- /dev/null
+++ b/spec/unit/type/file/ensure.rb
@@ -0,0 +1,21 @@
+#!/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") }
+
+property = Puppet::Type.type(:file).attrclass(:ensure)
+
+describe property do
+    before do
+        @resource = stub 'resource', :line => "foo", :file => "bar", :replace? => true
+        @resource.stubs(:[]).returns "foo"
+        @resource.stubs(:[]).with(:path).returns "/my/file"
+        @ensure = property.new :resource => @resource
+    end
+
+    describe "when testing whether in sync" do
+        it "should always be in sync if replace is 'false' unless the file is missing" do
+            @resource.expects(:replace?).returns false
+            @ensure.insync?(:link).should be_true
+        end
+    end
+end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list