summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-27 17:24:13 -0600
committerLuke Kanies <luke@madstop.com>2007-11-27 17:24:13 -0600
commit0ef6b9579df65adda51389a2ab3e514ef42afa14 (patch)
tree150340dc12e29d3b8397521e33e2baf60147d299 /spec/unit
parenta38b4151244c0af4bdf058d3fec5a01dc271e1c3 (diff)
downloadpuppet-0ef6b9579df65adda51389a2ab3e514ef42afa14.tar.gz
puppet-0ef6b9579df65adda51389a2ab3e514ef42afa14.tar.xz
puppet-0ef6b9579df65adda51389a2ab3e514ef42afa14.zip
Fixing #931 by keeping track in configurations of
what transportable resources get converted to, so different names don't throw it off. I also got rid of the Puppet::Type#merge method, which has been deprecated for ages but was still in there. I had to fix a few tests that weren't cleaning up after themselves as a result.
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/node/configuration.rb22
-rwxr-xr-xspec/unit/other/transbucket.rb3
-rwxr-xr-xspec/unit/ral/type.rb4
-rwxr-xr-xspec/unit/ral/types/file.rb12
4 files changed, 35 insertions, 6 deletions
diff --git a/spec/unit/node/configuration.rb b/spec/unit/node/configuration.rb
index 5780d4fbb..0a8b47fc5 100755
--- a/spec/unit/node/configuration.rb
+++ b/spec/unit/node/configuration.rb
@@ -292,6 +292,28 @@ describe Puppet::Node::Configuration, " when converting to a RAL configuration"
@config.vertices.each { |v| v.configuration.object_id.should equal(@config.object_id) }
end
+ # This tests #931.
+ it "should not lose track of resources whose names vary" do
+ changer = Puppet::TransObject.new 'changer', 'test'
+
+ config = Puppet::Node::Configuration.new('test')
+ config.add_resource(changer)
+ config.add_resource(@top)
+
+ config.add_edge!(@top, changer)
+
+ resource = stub 'resource', :name => "changer2", :title => "changer2", :ref => "Test[changer2]", :configuration= => nil, :remove => nil
+
+ changer.expects(:to_type).returns(resource)
+
+ newconfig = nil
+
+ Puppet::Type.allclear
+
+ proc { @config = config.to_ral }.should_not raise_error
+ @config.resource("Test[changer2]").should equal(resource)
+ end
+
after do
# Remove all resource instances.
@config.clear(true)
diff --git a/spec/unit/other/transbucket.rb b/spec/unit/other/transbucket.rb
index 0da808460..241529ebe 100755
--- a/spec/unit/other/transbucket.rb
+++ b/spec/unit/other/transbucket.rb
@@ -99,11 +99,13 @@ describe Puppet::TransBucket, " when generating a configuration" do
it "should only call to_type on each resource once" do
@topobj.expects(:to_type)
@bottomobj.expects(:to_type)
+ Puppet::Type.allclear
@top.to_configuration
end
it "should set each TransObject's configuration before converting to a RAL resource" do
@middleobj.expects(:configuration=).with { |c| c.is_a?(Puppet::Node::Configuration) }
+ Puppet::Type.allclear
@top.to_configuration
end
@@ -111,6 +113,7 @@ describe Puppet::TransBucket, " when generating a configuration" do
# each bucket is seen twice in the loop, so we have to handle the case where the config
# is set twice
@bottom.expects(:configuration=).with { |c| c.is_a?(Puppet::Node::Configuration) }.at_least_once
+ Puppet::Type.allclear
@top.to_configuration
end
diff --git a/spec/unit/ral/type.rb b/spec/unit/ral/type.rb
index c8bf8c9b4..adb40595e 100755
--- a/spec/unit/ral/type.rb
+++ b/spec/unit/ral/type.rb
@@ -22,4 +22,8 @@ describe Puppet::Type, " when in a configuration" do
it "should set its parent to its in edge" do
@one.parent.ref.should equal(@container.ref)
end
+
+ after do
+ @configuration.clear(true)
+ end
end
diff --git a/spec/unit/ral/types/file.rb b/spec/unit/ral/types/file.rb
index 823d643b0..1e20b06f4 100755
--- a/spec/unit/ral/types/file.rb
+++ b/spec/unit/ral/types/file.rb
@@ -1,18 +1,15 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'tempfile'
-describe Puppet::type(:file), " when used with replace=>false and content" do
+require 'puppet/type/pfile'
+describe Puppet::Type::File, " when used with replace=>false and content" do
before do
@path = Tempfile.new("puppetspec")
@path.close!()
@path = @path.path
- @file = Puppet::type(:file).create( { :name => @path, :content => "foo", :replace => :false } )
- end
-
- after do
+ @file = Puppet::Type::File.create( { :name => @path, :content => "foo", :replace => :false } )
end
it "should be insync if the file exists and the content is different" do
@@ -29,4 +26,7 @@ describe Puppet::type(:file), " when used with replace=>false and content" do
@file.property(:content).insync?(:nil).should be_false
end
+ after do
+ Puppet::Type::File.clear
+ end
end