diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-30 17:29:02 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-30 17:29:02 +0000 |
| commit | 3aafd81fa48d46737f1fe126bb3ff0d99520a180 (patch) | |
| tree | fc6a1fc229ee0242cc61d6e72dca5e94e7e1863e /test | |
| parent | c2bc8481eb2507c2127f5c67f698f85a222acb4a (diff) | |
| download | puppet-3aafd81fa48d46737f1fe126bb3ff0d99520a180.tar.gz puppet-3aafd81fa48d46737f1fe126bb3ff0d99520a180.tar.xz puppet-3aafd81fa48d46737f1fe126bb3ff0d99520a180.zip | |
Fixing #594 -- Files on the local machine but not remote machine now purge. Note that this introduces a difference in behaviour between recursing locally and recursing remotely.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2436 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rwxr-xr-x | test/ral/types/file.rb | 12 | ||||
| -rwxr-xr-x | test/ral/types/filesources.rb | 38 |
2 files changed, 46 insertions, 4 deletions
diff --git a/test/ral/types/file.rb b/test/ral/types/file.rb index e48b246d1..e58095764 100755 --- a/test/ral/types/file.rb +++ b/test/ral/types/file.rb @@ -567,7 +567,7 @@ class TestFile < Test::Unit::TestCase return_nil = false # and monkey-patch it - [:localrecurse, :sourcerecurse, :linkrecurse].each do |m| + [:localrecurse, :linkrecurse].each do |m| dir.meta_def(m) do |recurse| if return_nil # for testing nil return, of course return nil @@ -576,6 +576,16 @@ class TestFile < Test::Unit::TestCase end end end + + # We have to special-case this, because it returns a list of + # found files. + dir.meta_def(:sourcerecurse) do |recurse| + if return_nil # for testing nil return, of course + return nil + else + return [recurse], [] + end + end # First try it with recurse set to false dir[:recurse] = false diff --git a/test/ral/types/filesources.rb b/test/ral/types/filesources.rb index a3a00cf28..60d3214b6 100755 --- a/test/ral/types/filesources.rb +++ b/test/ral/types/filesources.rb @@ -273,9 +273,12 @@ class TestFileSources < Test::Unit::TestCase obj = Puppet::Type.newfile :source => source, :path => dest, :recurse => true result = nil + sourced = nil assert_nothing_raised do - result = obj.sourcerecurse(true) + result, sourced = obj.sourcerecurse(true) end + + assert_equal([destfile], sourced, "Did not get correct list of sourced objects") dfileobj = @file[destfile] assert(dfileobj, "Did not create destfile object") assert_equal([dfileobj], result) @@ -289,8 +292,9 @@ class TestFileSources < Test::Unit::TestCase result = nil assert_nothing_raised do - result = obj.sourcerecurse(true) + result, sourced = obj.sourcerecurse(true) end + assert_equal([destfile], sourced, "Did not get correct list of sourced objects") dfileobj = @file[destfile] assert(dfileobj, "Did not create destfile object with a missing source") assert_equal([dfileobj], result) @@ -300,8 +304,9 @@ class TestFileSources < Test::Unit::TestCase obj[:source] = [nosource, tempfile()] assert_nothing_raised do - result = obj.sourcerecurse(true) + result, sourced = obj.sourcerecurse(true) end + assert_equal([], sourced, "Did not get correct list of sourced objects") assert_equal([], result, "Sourcerecurse failed when all sources are missing") end @@ -1009,6 +1014,33 @@ class TestFileSources < Test::Unit::TestCase assert_equal("yay%s\n" % File.basename(file).sub("file", ''), File.read(path), "file was not copied correctly") end end + + # #594 + def test_purging_missing_remote_files + source = tempfile() + dest = tempfile() + s1 = File.join(source, "file1") + s2 = File.join(source, "file2") + d1 = File.join(dest, "file1") + d2 = File.join(dest, "file2") + Dir.mkdir(source) + [s1, s2].each { |name| File.open(name, "w") { |file| file.puts "something" } } + + # We have to add a second parameter, because that's the only way to expose the "bug". + file = Puppet::Type.newfile(:path => dest, :source => source, :recurse => true, :purge => true, :mode => "755") + + assert_apply(file) + + assert(FileTest.exists?(d1), "File1 was not copied") + assert(FileTest.exists?(d2), "File2 was not copied") + + File.unlink(s2) + + assert_apply(file) + + assert(FileTest.exists?(d1), "File1 was not kept") + assert(! FileTest.exists?(d2), "File2 was not purged") + end end # $Id$ |
