diff options
author | Jacob Helwig <jacob@puppetlabs.com> | 2011-02-25 17:03:56 -0800 |
---|---|---|
committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-03-15 10:29:20 -0700 |
commit | ff9e2425a58bb2b1ab836e440c3344b4012623c5 (patch) | |
tree | 6fa677aa40e356536b8520722c383102648bfed7 /spec | |
parent | 30fa41ddc3796e62a5bd1d0cf5116e14323992a3 (diff) | |
download | puppet-ff9e2425a58bb2b1ab836e440c3344b4012623c5.tar.gz puppet-ff9e2425a58bb2b1ab836e440c3344b4012623c5.tar.xz puppet-ff9e2425a58bb2b1ab836e440c3344b4012623c5.zip |
(#5428) More fully "stub" Puppet::Resource::Reference for use with storedconfigs
The Puppet::Resource::Reference class wasn't stubbing enough of the 0.25.x
behavior to satisfy the needs of storedconfigs. Since P::R::Reference,
and Puppet::Resource were merged as part of 2.6.x, we can pretend that
P::Resource is P::R::Reference for the purposes of loading data from
storedconfigs. This should still satisfy the over-the-wire serialization
needs of 0.25.x.
This also changes internal references to @parameters in
Puppet::Resource(::Reference) to go through a parameters method. This
allows us to "initialize" this instance variable lazily, since loading via
YAML bypasses the normal initialize method.
Paired-with: Daniel Pittman <daniel@puppetlabs.com>
Reviewed-by: Markus Roberts <markus@puppetlabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/resource_spec.rb | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index ff31b2492..4c1dc4952 100755 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -99,11 +99,11 @@ describe Puppet::Resource do end it 'should fail if strict is set and type does not exist' do - lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo') + lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo') end it 'should fail if strict is set and class does not exist' do - lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo') + lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo') end it "should fail if the title is a hash and the type is not a valid resource reference string" do @@ -463,6 +463,28 @@ describe Puppet::Resource do end end + describe "when loading 0.25.x storedconfigs YAML" do + before :each do + @old_storedconfig_yaml = %q{--- !ruby/object:Puppet::Resource::Reference +builtin_type: +title: /tmp/bar +type: File +} + end + + it "should deserialize a Puppet::Resource::Reference without exceptions" do + lambda { YAML.load(@old_storedconfig_yaml) }.should_not raise_error + end + + it "should deserialize as a Puppet::Resource::Reference as a Puppet::Resource" do + YAML.load(@old_storedconfig_yaml).class.should == Puppet::Resource + end + + it "should to_hash properly" do + YAML.load(@old_storedconfig_yaml).to_hash.should == { :path => "/tmp/bar" } + end + end + describe "when converting to a RAL resource" do it "should use the resource type's :new method to create the resource if the resource is of a builtin type" do resource = Puppet::Resource.new("file", @basepath+"/my/file") |