summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-24 14:48:13 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-24 23:39:14 -0700
commit59a23d69c20a8ab1f7dc9ff1d109305f9027641c (patch)
tree14df249a73f45d5627d0069c619b270f4e24d1e8 /spec/unit
parent865282ae7b9332fdbdfa51b2814755b8a13d244b (diff)
downloadpuppet-59a23d69c20a8ab1f7dc9ff1d109305f9027641c.tar.gz
puppet-59a23d69c20a8ab1f7dc9ff1d109305f9027641c.tar.xz
puppet-59a23d69c20a8ab1f7dc9ff1d109305f9027641c.zip
Fix for #3382 -- Empty classes as graph placeholders
As Brice discovered, the problem was that we simply ignored empty classes in the graph when determining application order. This patch instead replaces them with a resource of a new type which we've frequently noted the (internal) need for: a whit, the smallest possible resource, which has no properties or other semantics apart from its existence and its name. This resource then ensures application order through the normal mechanisms.
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/simple_graph_spec.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/unit/simple_graph_spec.rb b/spec/unit/simple_graph_spec.rb
index 83e674139..2ca8888c5 100755
--- a/spec/unit/simple_graph_spec.rb
+++ b/spec/unit/simple_graph_spec.rb
@@ -439,7 +439,8 @@ describe Puppet::SimpleGraph do
@middle = Container.new("middle", ["e", "f", @two])
@top = Container.new("top", ["g", "h", @middle, @one, @three])
@empty = Container.new("empty", [])
-
+
+ @whit = Puppet::Type.type(:whit)
@stage = Puppet::Type.type(:stage).new(:name => "foo")
@contgraph = @top.to_graph
@@ -499,8 +500,17 @@ describe Puppet::SimpleGraph do
end
end
+ it "should contain a whit-resource to mark the place held by the empty container" do
+ @depgraph.vertices.find_all { |v| v.is_a?(@whit) }.length.should == 1
+ end
+
+ it "should replace edges to empty containers with edges to their residual whit" do
+ emptys_whit = @depgraph.vertices.find_all { |v| v.is_a?(@whit) }.first
+ @depgraph.should be_edge("c", emptys_whit)
+ end
+
it "should no longer contain anything but the non-container objects" do
- @depgraph.vertices.find_all { |v| ! v.is_a?(String) }.should be_empty
+ @depgraph.vertices.find_all { |v| ! v.is_a?(String) and ! v.is_a?(@whit)}.should be_empty
end
it "should copy labels" do