summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-23 13:49:32 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-23 13:49:32 +0000
commitc285d7af0eea29e787eb889d393145da72402b56 (patch)
tree029348f6d15952429d9400c6693f3c59187b3e9b /test
parent9720a9764155b707126c2254fab3fa4d2516b352 (diff)
Fixing #437. Transactions now check whether graphs are cyclic, with a somewhat-useful error message if they are.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2079 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/other/pgraph.rb23
-rwxr-xr-xtest/other/transactions.rb13
2 files changed, 36 insertions, 0 deletions
diff --git a/test/other/pgraph.rb b/test/other/pgraph.rb
index f3999a459..e28decebb 100755
--- a/test/other/pgraph.rb
+++ b/test/other/pgraph.rb
@@ -192,6 +192,29 @@ class TestPGraph < Test::Unit::TestCase
assert_equal({:callback => :yay},
graph.edge_label(:a, :b), "lost label")
end
+
+ def test_check_cycle
+ {
+ {:a => :b, :b => :a} => true,
+ {:a => :b, :b => :c, :c => :a} => true,
+ {:a => :b, :b => :c} => false,
+ }.each do |hash, result|
+ graph = Puppet::PGraph.new
+ hash.each do |a,b|
+ graph.add_edge!(a, b)
+ end
+
+ if result
+ assert_raise(Puppet::Error, "%s did not fail" % hash.inspect) do
+ graph.check_cycle
+ end
+ else
+ assert_nothing_raised("%s failed" % hash.inspect) do
+ graph.check_cycle
+ end
+ end
+ end
+ end
end
# $Id$
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index d1ea0ef68..0a0bb5fd4 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -972,6 +972,19 @@ class TestTransactions < Test::Unit::TestCase
assert(! $called.include?(:refresh), "Called refresh when it wasn't set as a method")
end
+
+ # Testing #437 - cyclic graphs should throw failures.
+ def test_fail_on_cycle
+ one = Puppet::Type.type(:exec).create(:name => "/bin/echo one")
+ two = Puppet::Type.type(:exec).create(:name => "/bin/echo two")
+ one[:require] = two
+ two[:require] = one
+
+ trans = newcomp(one, two).evaluate
+ assert_raise(Puppet::Error) do
+ trans.relationship_graph
+ end
+ end
end
# $Id$