From c5782dfb9aa6ecfab045d348a7d07e38bcb4a8e2 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 12 Jan 2006 16:57:34 +0000 Subject: Adding "content" state to files, and string interpolation handles escaped whitespace characters. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@813 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/types/file.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test') diff --git a/test/types/file.rb b/test/types/file.rb index 4aee2a4e9..f0bcf8ed6 100644 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -587,6 +587,46 @@ class TestFile < Test::Unit::TestCase comp = newcomp(subobj, baseobj) assert_events([:directory_created, :file_created], comp) end + + def test_content + file = tempfile() + str = "This is some content" + + obj = nil + assert_nothing_raised { + obj = Puppet.type(:file).create( + :name => file, + :content => str + ) + } + + assert(!obj.insync?, "Object is incorrectly in sync") + + assert_events([:file_created], obj) + + obj.retrieve + + assert(obj.insync?, "Object is not in sync") + + text = File.read(file) + + assert_equal(str, text, "Content did not copy correctly") + + newstr = "Another string, yo" + + obj[:content] = newstr + + assert(!obj.insync?, "Object is incorrectly in sync") + + assert_events([:file_changed], obj) + + text = File.read(file) + + assert_equal(newstr, text, "Content did not copy correctly") + + obj.retrieve + assert(obj.insync?, "Object is not in sync") + end end # $Id$ -- cgit