diff options
| author | Luke Kanies <luke@madstop.com> | 2008-01-07 19:24:10 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-01-07 19:24:10 -0600 |
| commit | 40addcd1920b0fa2f558c415e65ea665bac812f9 (patch) | |
| tree | d2792c1d8c84d2cfaed6b48a4642d3ef29ba79c9 /spec/unit | |
| parent | 927dff41df8f1c236c54eaee9fa1db7a3efaf02a (diff) | |
| download | puppet-40addcd1920b0fa2f558c415e65ea665bac812f9.tar.gz puppet-40addcd1920b0fa2f558c415e65ea665bac812f9.tar.xz puppet-40addcd1920b0fa2f558c415e65ea665bac812f9.zip | |
Fixing #982 -- I have completely removed the GRATR graph library
from the system, and implemented my own topsort method.
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/other/pgraph.rb | 36 | ||||
| -rwxr-xr-x | spec/unit/relationship.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/simple_graph.rb | 40 |
3 files changed, 41 insertions, 37 deletions
diff --git a/spec/unit/other/pgraph.rb b/spec/unit/other/pgraph.rb index 41835ebc7..252a807ec 100755 --- a/spec/unit/other/pgraph.rb +++ b/spec/unit/other/pgraph.rb @@ -144,10 +144,6 @@ describe Puppet::PGraph, " when splicing the relationship graph" do splice end - it "should not create a cyclic graph" do - @depgraph.should_not be_cyclic - end - # This is the real heart of splicing -- replacing all containers in # our relationship and exploding their relationships so that each # relationship to a container gets copied to all of its children. @@ -211,35 +207,3 @@ describe Puppet::PGraph, " when splicing the relationship graph" do end end end - -describe Puppet::PGraph, " when sorting the graph" do - before do - @graph = Puppet::PGraph.new - end - - def add_edges(hash) - hash.each do |a,b| - @graph.add_edge!(a, b) - end - end - - it "should fail on two-vertex loops" do - add_edges :a => :b, :b => :a - proc { @graph.topsort }.should raise_error(Puppet::Error) - end - - it "should fail on multi-vertex loops" do - add_edges :a => :b, :b => :c, :c => :a - proc { @graph.topsort }.should raise_error(Puppet::Error) - end - - it "should fail when a larger tree contains a small cycle" do - add_edges :a => :b, :b => :a, :c => :a, :d => :c - proc { @graph.topsort }.should raise_error(Puppet::Error) - end - - it "should succeed on trees with no cycles" do - add_edges :a => :b, :b => :e, :c => :a, :d => :c - proc { @graph.topsort }.should_not raise_error - end -end diff --git a/spec/unit/relationship.rb b/spec/unit/relationship.rb index 5d90a9349..5f96cdf8c 100755 --- a/spec/unit/relationship.rb +++ b/spec/unit/relationship.rb @@ -24,7 +24,7 @@ describe Puppet::Relationship do end it "should provide a :ref method that describes the edge" do - @edge = Puppet::Relationship.new(stub("a", :ref => "a"), stub("b", :ref => "b")) + @edge = Puppet::Relationship.new("a", "b") @edge.ref.should == "a => b" end end diff --git a/spec/unit/simple_graph.rb b/spec/unit/simple_graph.rb index 88873663c..061a07458 100755 --- a/spec/unit/simple_graph.rb +++ b/spec/unit/simple_graph.rb @@ -219,6 +219,9 @@ describe Puppet::SimpleGraph, " when reversing graphs" do end it "should add all vertices to the reversed graph" do + @graph.add_edge!(:one, :two) + @graph.vertex?(:one).should be_true + @graph.vertex?(:two).should be_true end it "should retain labels on edges" do @@ -227,3 +230,40 @@ describe Puppet::SimpleGraph, " when reversing graphs" do edge.label.should == {:stuff => :awesome} end end + +describe Puppet::SimpleGraph, " when sorting the graph" do + before do + @graph = Puppet::SimpleGraph.new + end + + def add_edges(hash) + hash.each do |a,b| + @graph.add_edge!(a, b) + end + end + + it "should sort the graph topologically" do + add_edges :a => :b, :b => :c + @graph.topsort.should == [:a, :b, :c] + end + + it "should fail on two-vertex loops" do + add_edges :a => :b, :b => :a + proc { @graph.topsort }.should raise_error(Puppet::Error) + end + + it "should fail on multi-vertex loops" do + add_edges :a => :b, :b => :c, :c => :a + proc { @graph.topsort }.should raise_error(Puppet::Error) + end + + it "should fail when a larger tree contains a small cycle" do + add_edges :a => :b, :b => :a, :c => :a, :d => :c + proc { @graph.topsort }.should raise_error(Puppet::Error) + end + + it "should succeed on trees with no cycles" do + add_edges :a => :b, :b => :e, :c => :a, :d => :c + proc { @graph.topsort }.should_not raise_error + end +end |
