diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-08 17:28:28 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-08 17:28:28 +0000 |
| commit | e73f2d479f4d3f1ea84016ee554f729d78808620 (patch) | |
| tree | 09532f188435d624df810f57e3e9b9f18c3bf0b6 /test | |
| parent | 4266f64ed5eea79e939c39b18861685a5b5a8ec7 (diff) | |
| download | puppet-e73f2d479f4d3f1ea84016ee554f729d78808620.tar.gz puppet-e73f2d479f4d3f1ea84016ee554f729d78808620.tar.xz puppet-e73f2d479f4d3f1ea84016ee554f729d78808620.zip | |
Fixing #158. I did not add a force option, since I always back files up before I replace them.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1244 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rw-r--r-- | test/types/file.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/types/file.rb b/test/types/file.rb index e3f01d306..69ffad85e 100644 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -1159,6 +1159,51 @@ class TestFile < Test::Unit::TestCase assert_events([:file_changed, :file_changed], obj) end + + def test_replacefilewithlink + path = tempfile() + link = tempfile() + + File.open(path, "w") { |f| f.puts "yay" } + File.open(link, "w") { |f| f.puts "a file" } + + file = nil + assert_nothing_raised { + file = Puppet.type(:file).create( + :ensure => path, + :path => link + ) + } + + assert_events([:link_created], file) + + assert(FileTest.symlink?(link), "Link was not created") + + assert_equal(path, File.readlink(link), "Link was created incorrectly") + end + + def test_replacedirwithlink + path = tempfile() + link = tempfile() + + File.open(path, "w") { |f| f.puts "yay" } + Dir.mkdir(link) + File.open(File.join(link, "yay"), "w") do |f| f.puts "boo" end + + file = nil + assert_nothing_raised { + file = Puppet.type(:file).create( + :ensure => path, + :path => link + ) + } + + assert_events([:link_created], file) + + assert(FileTest.symlink?(link), "Link was not created") + + assert_equal(path, File.readlink(link), "Link was created incorrectly") + end end # $Id$ |
