[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.7-1-98-gf19c0e5
Luke Kanies
luke at madstop.com
Wed Apr 8 21:48:14 UTC 2009
The following commit has been merged in the master branch:
commit 44f97aa5815d4a8ab73302bd75b85e045f9944c4
Author: Luke Kanies <luke at madstop.com>
Date: Sat Feb 14 11:43:25 2009 -0600
Only backing up within parsedfile when managing files
I was getting failing tests because I was using non-files
for testing and they didn't back up the same, not
surprisingly.
This moves the 'backup' method to the :flat filetype
and then only backs up if the filetype supports it.
Signed-off-by: Luke Kanies <luke at madstop.com>
diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb
index 45eae57..40e1727 100755
--- a/lib/puppet/provider/parsedfile.rb
+++ b/lib/puppet/provider/parsedfile.rb
@@ -81,6 +81,8 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
# Make sure our file is backed up, but only back it up once per transaction.
# We cheat and rely on the fact that @records is created on each prefetch.
def self.backup_target(target)
+ return nil unless target_object(target).respond_to?(:backup)
+
unless defined?(@backup_stats)
@backup_stats = {}
end
diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb
index 5d4ba14..40c028c 100755
--- a/lib/puppet/util/filetype.rb
+++ b/lib/puppet/util/filetype.rb
@@ -72,11 +72,6 @@ class Puppet::Util::FileType
@filetypes[type]
end
- # Back the file up before replacing it.
- def backup
- bucket.backup(@path) if File.exists?(@path)
- end
-
# Pick or create a filebucket to use.
def bucket
filebucket = Puppet::Type.type(:filebucket)
@@ -90,6 +85,11 @@ class Puppet::Util::FileType
# Operate on plain files.
newfiletype(:flat) do
+ # Back the file up before replacing it.
+ def backup
+ bucket.backup(@path) if File.exists?(@path)
+ end
+
# Read the file.
def read
if File.exist?(@path)
diff --git a/spec/unit/provider/parsedfile.rb b/spec/unit/provider/parsedfile.rb
index 11a91c8..f20b6b2 100755
--- a/spec/unit/provider/parsedfile.rb
+++ b/spec/unit/provider/parsedfile.rb
@@ -56,18 +56,27 @@ describe Puppet::Provider::ParsedFile do
@class.initvars
@class.prefetch
- @filetype = mock 'filetype'
- Puppet::Util::FileType.filetype(:flat).expects(:new).with("/my/file").returns @filetype
+ @filetype = Puppet::Util::FileType.filetype(:flat).new("/my/file")
+ Puppet::Util::FileType.filetype(:flat).stubs(:new).with("/my/file").returns @filetype
@filetype.stubs(:write)
end
- it "should back up the file being written" do
+ it "should back up the file being written if the filetype can be backed up" do
@filetype.expects(:backup)
@class.flush_target("/my/file")
end
+ it "should not try to back up the file if the filetype cannot be backed up" do
+ @filetype = Puppet::Util::FileType.filetype(:ram).new("/my/file")
+ Puppet::Util::FileType.filetype(:flat).expects(:new).returns @filetype
+
+ @filetype.stubs(:write)
+
+ @class.flush_target("/my/file")
+ end
+
it "should not back up the file more than once between calls to 'prefetch'" do
@filetype.expects(:backup).once
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list