From bf43c76deddb8475fea43515ebd530b5d3f331a2 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 21 Aug 2006 22:54:17 +0000 Subject: Fixing #228. The real problem was that "present" should match any type of file existence, whereas it was just matching files. If the file was a directory, as in this case, Puppet considered it to be out of sync. Now, "present" matches files, links, or directories, but still creates an empty file if the path is missing. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1477 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/types/file.rb | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'test') diff --git a/test/types/file.rb b/test/types/file.rb index eeb976370..551d96d89 100644 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -1310,6 +1310,47 @@ class TestFile < Test::Unit::TestCase assert(FileTest.exists?(dest), "File did not get created") end + + def test_present_matches_anything + path = tempfile() + + file = Puppet::Type.newfile(:path => path, :ensure => :present) + + file.retrieve + assert(! file.insync?, "File incorrectly in sync") + + # Now make a file + File.open(path, "w") { |f| f.puts "yay" } + + file.retrieve + assert(file.insync?, "File not in sync") + + # Now make a directory + File.unlink(path) + Dir.mkdir(path) + + file.retrieve + assert(file.insync?, "Directory not considered 'present'") + + Dir.rmdir(path) + + # Now make a link + file[:links] = :manage + + otherfile = tempfile() + File.symlink(otherfile, path) + + file.retrieve + assert(file.insync?, "Symlink not considered 'present'") + File.unlink(path) + + # Now set some content, and make sure it works + file[:content] = "yayness" + + assert_apply(file) + + assert_equal("yayness", File.read(path), "Content did not get set correctly") + end end # $Id$ -- cgit