diff options
| author | Luke Kanies <luke@puppetlabs.com> | 2010-05-20 17:30:59 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | 2b5bd4927569c0a87ea32628cdc4303ff1e83853 (patch) | |
| tree | b11f947c352df68abe53d4bd72e16c87d06b88c2 /spec | |
| parent | 94390de11d046d4906842f33aa9865f6c3835633 (diff) | |
| download | puppet-2b5bd4927569c0a87ea32628cdc4303ff1e83853.tar.gz puppet-2b5bd4927569c0a87ea32628cdc4303ff1e83853.tar.xz puppet-2b5bd4927569c0a87ea32628cdc4303ff1e83853.zip | |
Fixing #3822 - checksums will be loaded from filebuckets
If you have the following code or equivalent:
file { "/foo": content => "{md5}foobar" }
Puppet will attempt to pull the content associated with
that file from whatever the default filebucket is for the
resource in question.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/type/file/content.rb | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/spec/unit/type/file/content.rb b/spec/unit/type/file/content.rb index 2289215bb..f1001aa8c 100755 --- a/spec/unit/type/file/content.rb +++ b/spec/unit/type/file/content.rb @@ -13,10 +13,6 @@ describe content do end describe "when determining the checksum type" do - before do - @resource = Puppet::Type.type(:file).new :path => "/foo/bar" - end - it "should use the type specified in the source checksum if a source is set" do @resource[:source] = "/foo" @resource.parameter(:source).expects(:checksum).returns "{md5lite}eh" @@ -34,10 +30,6 @@ describe content do end describe "when determining the actual content to write" do - before do - @resource = Puppet::Type.type(:file).new :path => "/foo/bar" - end - it "should use the set content if available" do @content = content.new(:resource => @resource) @content.should = "ehness" @@ -254,8 +246,10 @@ describe content do @fh = stub_everything end - it "should fail if no actual content nor source exists" do - lambda { @content.write(@fh) }.should raise_error + it "should attempt to read from the filebucket if no actual content nor source exists" do + @content.should = "{md5}foo" + @content.resource.bucket.class.any_instance.stubs(:getfile).returns "foo" + @content.write(@fh) end describe "from actual content" do @@ -274,6 +268,32 @@ describe content do end end + describe "from a file bucket" do + it "should fail if a file bucket cannot be retrieved" do + @content.should = "{md5}foo" + @content.resource.expects(:bucket).returns nil + lambda { @content.write(@fh) }.should raise_error(Puppet::Error) + end + + it "should fail if the file bucket cannot find any content" do + @content.should = "{md5}foo" + bucket = stub 'bucket' + @content.resource.expects(:bucket).returns bucket + bucket.expects(:getfile).with("foo").raises "foobar" + lambda { @content.write(@fh) }.should raise_error(Puppet::Error) + end + + it "should write the returned content to the file" do + @content.should = "{md5}foo" + bucket = stub 'bucket' + @content.resource.expects(:bucket).returns bucket + bucket.expects(:getfile).with("foo").returns "mycontent" + + @fh.expects(:print).with("mycontent") + @content.write(@fh) + end + end + describe "from local source" do before(:each) do @content.stubs(:actual_content).returns(nil) @@ -432,5 +452,8 @@ describe content do @content.write(@fh) end end + + describe "from a filebucket" do + end end end |
