summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-11-16 22:17:29 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-11-16 22:17:29 +0000
commitc205bf6ba79a905c59eb99747ffe674bbaa11481 (patch)
tree4b045649f13bc4023e7be75185a7c6baa532a3bd
parent69600345c1f092cc55320d52e4e75dccc12b1dac (diff)
downloadpuppet-c205bf6ba79a905c59eb99747ffe674bbaa11481.tar.gz
fixing filesources so that the first found file is copied, and adding a test case
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@745 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xlib/puppet/type/pfile/source.rb10
-rw-r--r--test/puppettest.rb4
-rwxr-xr-xtest/types/filesources.rb31
3 files changed, 42 insertions, 3 deletions
diff --git a/lib/puppet/type/pfile/source.rb b/lib/puppet/type/pfile/source.rb
index 625458b23..a035878b1 100755
--- a/lib/puppet/type/pfile/source.rb
+++ b/lib/puppet/type/pfile/source.rb
@@ -29,7 +29,9 @@ module Puppet
if value =~ /^[0-9]+$/
value = value.to_i
end
- args[param] = value
+ unless value.nil?
+ args[param] = value
+ end
}
# we can't manage ownership as root, so don't even try
@@ -37,7 +39,11 @@ module Puppet
args.delete(:owner)
end
- return args
+ if args.empty?
+ return nil
+ else
+ return args
+ end
end
# This basically calls describe() on our file, and then sets all
diff --git a/test/puppettest.rb b/test/puppettest.rb
index 20bfb439d..604d95d81 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -8,6 +8,10 @@ require 'test/unit'
module TestPuppet
def newcomp(name,*ary)
+ if name.is_a?(Puppet::Type)
+ ary.unshift name
+ name = name.name
+ end
comp = Puppet::Type::Component.create(
:name => name
)
diff --git a/test/types/filesources.rb b/test/types/filesources.rb
index b62171202..45cfd3784 100755
--- a/test/types/filesources.rb
+++ b/test/types/filesources.rb
@@ -528,7 +528,7 @@ class TestFileSources < Test::Unit::TestCase
assert(!FileTest.exists?(name), "File with no source exists anyway")
end
- def test_zalwayschecksum
+ def test_alwayschecksum
from = tempfile()
to = tempfile()
@@ -553,6 +553,35 @@ class TestFileSources < Test::Unit::TestCase
assert_equal(0, file.evaluate.length, "File produced changes")
end
+
+ def test_sourcepaths
+ files = []
+ 3.times {
+ files << tempfile()
+ }
+
+ to = tempfile()
+
+ File.open(files[-1], "w") { |f| f.puts "yee-haw" }
+
+ file = nil
+ assert_nothing_raised {
+ file = Puppet::Type::PFile.create(
+ :name => to,
+ :source => files
+ )
+ }
+
+ comp = newcomp(file)
+ assert_events(comp, [:file_changed])
+
+ assert(File.exists?(to), "File does not exist")
+
+ txt = nil
+ File.open(to) { |f| txt = f.read.chomp }
+
+ assert_equal("yee-haw", txt, "Contents do not match")
+ end
end
# $Id$