summaryrefslogtreecommitdiffstats
path: root/spec/unit/other
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-15 22:17:20 -0600
committerLuke Kanies <luke@madstop.com>2007-09-15 22:17:20 -0600
commitf17f19dae941b17a56c1fc83ed3a89712b98c427 (patch)
tree3615e9be9ed585511bbe0b85737208bbd85f00f0 /spec/unit/other
parent3ccf483f77b026dde8a53bd8e9dff6a5fd0f6722 (diff)
downloadpuppet-f17f19dae941b17a56c1fc83ed3a89712b98c427.tar.gz
puppet-f17f19dae941b17a56c1fc83ed3a89712b98c427.tar.xz
puppet-f17f19dae941b17a56c1fc83ed3a89712b98c427.zip
The whole system now uses Configuration objects instead of
ever converting the Transportable objects into a tree of components and then converting that into a graph. This is a significant step, and drastically simplifies the model of how to use a configuration. The old code might have looked something like this: file = Puppet::Type.create :path => "/whatever", ... comp = Puppet::Type.create :name => :whatever comp.push file transaction = comp.evaluate transaction.evaluate The new code looks like this: file = Puppet::Type.create :path => "/whatever", ... config = Puppet::Node::Configuration.new config.add_resource file config.apply I did not really intend to do this much refactoring, but I found I could not use a Configuration object to do work without refactoring a lot of the system. The primary problem was that the Client::Master and the Config classes determined how the transactions behaved; when I moved to using a Configuration, this distinction was lost, which meant that configurations were often needing to create other configurations, which resulted in a whole lot of infinite recursion (e.g., Config objects that create directories for Puppet use Configuration objects -- yes, I'm s/Config/Settings/g soon -- and these Configuration objects would need to create directories). Not everything is fixed, but it's very close. I am clearly over the hump, though, so I wanted to get a commit in.
Diffstat (limited to 'spec/unit/other')
-rwxr-xr-xspec/unit/other/transbucket.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/spec/unit/other/transbucket.rb b/spec/unit/other/transbucket.rb
index c013973ee..8cb9abaa4 100755
--- a/spec/unit/other/transbucket.rb
+++ b/spec/unit/other/transbucket.rb
@@ -48,7 +48,7 @@ describe Puppet::TransBucket do
end
end
-describe Puppet::TransBucket, " when generating a resource graph" do
+describe Puppet::TransBucket, " when generating a configuration" do
before do
@bottom = Puppet::TransBucket.new
@bottom.type = "fake"
@@ -70,7 +70,7 @@ describe Puppet::TransBucket, " when generating a resource graph" do
@top.push(@topobj)
@top.push(@middle)
- @graph = @top.to_graph
+ @config = @top.to_configuration
@users = %w{top middle bottom}
@fakes = %w{fake[bottom] fake[middle] fake[top]}
@@ -78,18 +78,28 @@ describe Puppet::TransBucket, " when generating a resource graph" do
it "should convert all transportable objects to RAL resources" do
@users.each do |name|
- @graph.vertices.find { |r| r.class.name == :user and r.title == name }.should be_instance_of(Puppet::Type.type(:user))
+ @config.vertices.find { |r| r.class.name == :user and r.title == name }.should be_instance_of(Puppet::Type.type(:user))
end
end
it "should convert all transportable buckets to RAL components" do
@fakes.each do |name|
- @graph.vertices.find { |r| r.class.name == :component and r.title == name }.should be_instance_of(Puppet::Type.type(:component))
+ @config.vertices.find { |r| r.class.name == :component and r.title == name }.should be_instance_of(Puppet::Type.type(:component))
end
end
it "should add all resources to the graph's resource table" do
- @graph.resource("fake[top]").should equal(@top)
+ @config.resource("fake[top]").should equal(@top)
+ end
+
+ it "should finalize all resources" do
+ @config.vertices.each do |vertex| vertex.should be_finalized end
+ end
+
+ it "should only call to_type on each resource once" do
+ @topobj.expects(:to_type)
+ @bottomobj.expects(:to_type)
+ @top.to_configuration
end
after do