diff options
author | Luke Kanies <luke@puppetlabs.com> | 2010-04-12 11:06:06 -0700 |
---|---|---|
committer | Luke Kanies <luke@puppetlabs.com> | 2010-04-12 11:06:06 -0700 |
commit | effa7196781c2c233935206388c7e18d410e8e5f (patch) | |
tree | 1a9f6446eebb728ed14cf20f4a13f8e672190659 /spec | |
parent | 456447cab21ef6cfa66a6fbb949146e0d1df462c (diff) | |
download | puppet-effa7196781c2c233935206388c7e18d410e8e5f.tar.gz puppet-effa7196781c2c233935206388c7e18d410e8e5f.tar.xz puppet-effa7196781c2c233935206388c7e18d410e8e5f.zip |
Cleaning up content/source code
This is probably a slight refactor, but only because
it fixed a bug (content not being copied over correctly
from metadata), which required that slight refactor.
Mostly this just makes the code a bit cleaner.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/type/file/content.rb | 26 | ||||
-rwxr-xr-x | spec/unit/type/file/source.rb | 15 |
2 files changed, 5 insertions, 36 deletions
diff --git a/spec/unit/type/file/content.rb b/spec/unit/type/file/content.rb index 1f2100981..5a3a8598d 100755 --- a/spec/unit/type/file/content.rb +++ b/spec/unit/type/file/content.rb @@ -201,32 +201,6 @@ describe content do @content.insync?("{md5}" + Digest::MD5.hexdigest("some content")) end end - - describe "and the content is specified via a remote source" do - before do - @metadata = stub 'metadata' - @source = stub 'source', :metadata => @metadata - @resource.stubs(:parameter).with(:source).returns @source - end - - it "should use checksums to compare remote content, rather than downloading the content" do - @source.stubs(:checksum).returns "{md5}whatever" - - @content.insync?("{md5}eh") - end - - it "should return false if the current content is different from the remote content" do - @source.stubs(:checksum).returns "{md5}whatever" - - @content.should_not be_insync("some content") - end - - it "should return true if the current content is the same as the remote content" do - @source.stubs(:checksum).returns("{md5}something") - - @content.must be_insync("{md5}something") - end - end end describe "and :replace is false" do diff --git a/spec/unit/type/file/source.rb b/spec/unit/type/file/source.rb index 8dd2ff381..e4e9ad9d1 100755 --- a/spec/unit/type/file/source.rb +++ b/spec/unit/type/file/source.rb @@ -147,7 +147,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do @metadata.stubs(:ftype).returns "file" end - it "should copy the metadata's owner, group, and mode to the resource if they are not set on the resource" do + it "should copy the metadata's owner, group, checksum, and mode to the resource if they are not set on the resource" do Puppet::Util::SUIDManager.expects(:uid).returns 0 @source.copy_source_values @@ -155,28 +155,23 @@ describe Puppet::Type.type(:file).attrclass(:source) do @resource[:owner].must == 100 @resource[:group].must == 200 @resource[:mode].must == 123 - end - - it "should copy the metadata's owner, group, and mode to the resource if they are set to :absent on the resource" do - Puppet::Util::SUIDManager.expects(:uid).returns 0 - - @source.copy_source_values - @resource[:owner].must == 100 - @resource[:group].must == 200 - @resource[:mode].must == 123 + # Metadata calls it checksum, we call it content. + @resource[:content].must == @metadata.checksum end it "should not copy the metadata's owner to the resource if it is already set" do @resource[:owner] = 1 @resource[:group] = 2 @resource[:mode] = 3 + @resource[:content] = "foobar" @source.copy_source_values @resource[:owner].must == 1 @resource[:group].must == 2 @resource[:mode].must == 3 + @resource[:content].should_not == @metadata.checksum end describe "and puppet is not running as root" do |