diff options
Diffstat (limited to 'test/ral/type/file/target.rb')
-rwxr-xr-x | test/ral/type/file/target.rb | 75 |
1 files changed, 60 insertions, 15 deletions
diff --git a/test/ral/type/file/target.rb b/test/ral/type/file/target.rb index 89792c4b6..6b252d28f 100755 --- a/test/ral/type/file/target.rb +++ b/test/ral/type/file/target.rb @@ -24,9 +24,12 @@ class TestFileTarget < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :title => "somethingelse", :ensure => path, + :path => link ) } @@ -52,9 +55,12 @@ class TestFileTarget < Test::Unit::TestCase system("mkdir -p %s" % subdir) system("touch %s" % file) - link = Puppet::Type.type(:file).new( + + link = Puppet::Type.type(:file).new( + :ensure => source, :path => path, + :recurse => true ) @@ -96,9 +102,12 @@ class TestFileTarget < Test::Unit::TestCase link = nil assert_nothing_raised { - link = Puppet::Type.type(:file).new( + + link = Puppet::Type.type(:file).new( + :ensure => source, :path => dest, + :recurse => true ) } @@ -131,8 +140,11 @@ class TestFileTarget < Test::Unit::TestCase link = nil assert_nothing_raised { - link = Puppet::Type.type(:file).new( + + link = Puppet::Type.type(:file).new( + :path => dest, + :ensure => "source" ) } @@ -148,15 +160,21 @@ class TestFileTarget < Test::Unit::TestCase dest = tempfile() resources = [] - resources << Puppet::Type.type(:exec).new( + + resources << Puppet::Type.type(:exec).new( + :command => "mkdir %s; touch %s/file" % [source, source], :title => "yay", + :path => ENV["PATH"] ) - resources << Puppet::Type.type(:file).new( + + resources << Puppet::Type.type(:file).new( + :ensure => source, :path => dest, :recurse => true, + :require => resources[0] ) @@ -175,19 +193,28 @@ class TestFileTarget < Test::Unit::TestCase prop = obj.send(:property, :target) prop.send(:instance_variable_set, "@should", [:nochange]) - assert(prop.insync?(prop.retrieve), + + assert( + prop.insync?(prop.retrieve), + "Property not in sync with should == :nochange") prop = obj.send(:property, :target) prop.send(:instance_variable_set, "@should", [:notlink]) - assert(prop.insync?(prop.retrieve), + + assert( + prop.insync?(prop.retrieve), + "Property not in sync with should == :nochange") # Lastly, make sure that we don't try to do anything when we're # recursing, since 'ensure' does the work. obj[:recurse] = true prop.should = dest - assert(prop.insync?(prop.retrieve), + + assert( + prop.insync?(prop.retrieve), + "Still out of sync during recursion") end @@ -202,9 +229,12 @@ class TestFileTarget < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :ensure => path, :path => link, + :backup => false ) } @@ -233,14 +263,20 @@ class TestFileTarget < Test::Unit::TestCase File.open(file, "w") { |f| f.puts "yayness" } File.symlink(file, link) - obj = Puppet::Type.type(:file).new( + + obj = Puppet::Type.type(:file).new( + :path => link, + :ensure => "file" ) assert_apply(obj) - assert_equal("yayness\n", File.read(file), + + assert_equal( + "yayness\n", File.read(file), + "Original file got changed") assert_equal("file", File.lstat(link).ftype, "File is still a link") end @@ -264,10 +300,13 @@ class TestFileTarget < Test::Unit::TestCase File.open(sourcefile, "w") { |f| f.puts "source" } File.symlink(file, link) - obj = Puppet::Type.type(:file).new( + + obj = Puppet::Type.type(:file).new( + :path => dirs["target"], :ensure => :file, :source => dirs["source"], + :recurse => true ) config = mk_catalog obj @@ -281,7 +320,10 @@ class TestFileTarget < Test::Unit::TestCase assert_equal(File.read(sourcefile), File.read(newfile), "File did not get copied correctly.") - assert_equal("other\n", File.read(file), + + assert_equal( + "other\n", File.read(file), + "Original file got changed") assert_equal("file", File.lstat(link).ftype, "File is still a link") end @@ -294,8 +336,11 @@ class TestFileTarget < Test::Unit::TestCase File.open(dest, "w") { |f| f.puts "boo" } File.open(otherdest, "w") { |f| f.puts "yay" } - obj = Puppet::Type.type(:file).new( + + obj = Puppet::Type.type(:file).new( + :path => link, + :ensure => otherdest ) |