diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-13 16:40:12 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-13 16:40:12 +0000 |
commit | ab604527648e91b84529c3fb83761b5e9b269b77 (patch) | |
tree | ae37547f9ca127bd41d305ab58b2b3ff2e1959bc /test | |
parent | 3937aa3519652612899b5d22e3f99ffb9aa8c40c (diff) | |
download | puppet-ab604527648e91b84529c3fb83761b5e9b269b77.tar.gz puppet-ab604527648e91b84529c3fb83761b5e9b269b77.tar.xz puppet-ab604527648e91b84529c3fb83761b5e9b269b77.zip |
Fixing the next round of bugs, mostly little things but I had to modify transactions so they are willing to delete implicit resources even if they have dependencies, else we would often not be able to purge files at all.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1917 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-x | test/other/events.rb | 3 | ||||
-rw-r--r-- | test/other/pgraph.rb | 18 | ||||
-rwxr-xr-x | test/other/transactions.rb | 21 | ||||
-rwxr-xr-x | test/types/file.rb | 24 | ||||
-rwxr-xr-x | test/types/type.rb | 2 |
5 files changed, 46 insertions, 22 deletions
diff --git a/test/other/events.rb b/test/other/events.rb index 10099fa46..078e6351f 100755 --- a/test/other/events.rb +++ b/test/other/events.rb @@ -146,7 +146,8 @@ class TestEvents < Test::Unit::TestCase exec3 = Puppet.type(:exec).create( :title => "three", :name => "echo three >> %s" % file, - :path => "/usr/bin:/bin" + :path => "/usr/bin:/bin", + :require => exec2 ) execs = [exec1, exec2, exec3] diff --git a/test/other/pgraph.rb b/test/other/pgraph.rb index 1ef853cc4..5ee76bfe9 100644 --- a/test/other/pgraph.rb +++ b/test/other/pgraph.rb @@ -58,9 +58,15 @@ class TestPGraph < Test::Unit::TestCase graph.add_edge!("a", "c") graph.add_edge!("b", "d") - assert_equal(%w{b c d}.sort, graph.dependencies("a").sort) - assert_equal(%w{d}.sort, graph.dependencies("b").sort) - assert_equal([].sort, graph.dependencies("c").sort) + assert_equal(%w{b c d}.sort, graph.dependents("a").sort) + assert_equal(%w{d}.sort, graph.dependents("b").sort) + assert_equal([].sort, graph.dependents("c").sort) + + assert_equal(%w{a b}, graph.dependencies("d").sort) + assert_equal(%w{a}, graph.dependencies("b").sort) + assert_equal(%w{a}, graph.dependencies("c").sort) + assert_equal([], graph.dependencies("a").sort) + end # Test that we can take a containment graph and rearrange it by dependencies @@ -110,17 +116,11 @@ class TestPGraph < Test::Unit::TestCase assert(nons.empty?, "still contain non-strings %s" % nons.inspect) - deps.to_jpg("deps-after") - deps.edges.each do |edge| assert_equal({:callback => :refresh}, edge.label, "Label was not copied on splice") end end - - # Make sure empty containers are also removed - def test_empty_splice - end end # $Id$ diff --git a/test/other/transactions.rb b/test/other/transactions.rb index 4190ada3a..256c815f7 100755 --- a/test/other/transactions.rb +++ b/test/other/transactions.rb @@ -760,11 +760,26 @@ class TestTransactions < Test::Unit::TestCase trans.tags = %w{mytag yaytag} assert(trans.tagged?(res), "tags should have matched") - end - # Make sure events propagate down the relationship graph appropriately. - def test_trigger + # We don't want to purge resources that have relationships with other resources, + # so we want our transactions to check for that. + def test_required_resources_not_deleted + @file = Puppet::Type.type(:file) + path1 = tempfile() + path2 = tempfile() + + # Create our first file + File.open(path1, "w") { |f| f.puts "yay" } + + # Create a couple of related resources + file1 = @file.create :title => "dependee", :path => path1, :ensure => :absent + file2 = @file.create :title => "depender", :path => path2, :content => "some stuff", :require => file1 + + # Now make sure we don't actually delete the first file + assert_apply(file1, file2) + + assert(FileTest.exists?(path1), "required file was deleted") end end diff --git a/test/types/file.rb b/test/types/file.rb index c57129cd5..917b2e755 100755 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -1559,30 +1559,38 @@ class TestFile < Test::Unit::TestCase sourcefile = File.join(sourcedir, "sourcefile") dsourcefile = File.join(destdir, "sourcefile") localfile = File.join(destdir, "localfile") - randfile = File.join(destdir, "random") + purgee = File.join(destdir, "to_be_purged") File.open(sourcefile, "w") { |f| f.puts "funtest" } # this file should get removed - File.open(randfile, "w") { |f| f.puts "footest" } + File.open(purgee, "w") { |f| f.puts "footest" } - lfobj = Puppet::Type.newfile(:path => localfile, :content => "rahtest") + lfobj = Puppet::Type.newfile(:title => "localfile", :path => localfile, :content => "rahtest") - destobj = Puppet::Type.newfile(:path => destdir, + destobj = Puppet::Type.newfile(:title => "destdir", :path => destdir, :source => sourcedir, :recurse => true) - assert_apply(lfobj, destobj) + puts "a" + comp = newcomp(lfobj, destobj) + # trans = comp.evaluate + assert_apply(comp) + # assert_nothing_raised { trans.evaluate } + puts "b" + # graph = trans.relgraph + # graph.to_jpg("/Users/luke/Desktop/pics", "purging") assert(FileTest.exists?(dsourcefile), "File did not get copied") assert(FileTest.exists?(localfile), "File did not get created") - assert(FileTest.exists?(randfile), "File got prematurely purged") + assert(FileTest.exists?(purgee), "File got prematurely purged") assert_nothing_raised { destobj[:purge] = true } - assert_apply(lfobj, destobj) + assert_apply(comp) + system("find %s" % destdir) assert(FileTest.exists?(dsourcefile), "File got purged") assert(FileTest.exists?(localfile), "File got purged") - assert(! FileTest.exists?(randfile), "File did not get purged") + assert(! FileTest.exists?(purgee), "File did not get purged") end # Testing #274. Make sure target can be used without 'ensure'. diff --git a/test/types/type.rb b/test/types/type.rb index ade0275b8..aa37f2a18 100755 --- a/test/types/type.rb +++ b/test/types/type.rb @@ -753,7 +753,7 @@ end def test_ref path = tempfile() file = Puppet::Type.newfile(:path => path) - assert_equal("file[#{path}]", file.ref) + assert_equal("File[#{path}]", file.ref) exec = Puppet::Type.newexec(:title => "yay", :command => "/bin/echo yay") assert_equal("exec[yay]", exec.ref) |