diff options
author | Nick Lewis <nick@puppetlabs.com> | 2011-07-21 11:41:04 -0700 |
---|---|---|
committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-08-19 13:52:56 -0700 |
commit | d49dd9ec3ab26d122c5c2a78482136f2a5f3efda (patch) | |
tree | 7214ef323e1a9728841287096a7ccef4529b09fc /spec | |
parent | 546e0f98e3c6bfcb35163d1c6c19e0b4cb02e230 (diff) | |
download | puppet-d49dd9ec3ab26d122c5c2a78482136f2a5f3efda.tar.gz puppet-d49dd9ec3ab26d122c5c2a78482136f2a5f3efda.tar.xz puppet-d49dd9ec3ab26d122c5c2a78482136f2a5f3efda.zip |
Remove cached_attrs from Puppet::Type::File
These values needn't be cached_attrs, because they can be managed manually.
'stat' does need to be cached, so that we avoid statting the file for each
property we want to check from disk. The 'content' attribute of 'source' also
needs to be cached, because it's retrieved from the server, which we certainly
don't want to do multiple times.
We need a mechanism for invalidating the 'stat' after we've written the file,
so we use a special value :needs_stat, which essentially represented
"undefined". We use this rather than nil so that we can store a failed stat
if it occurs.
Because the content and metadata of our source file will never change, there is
no need to be able to similarly expire the values of those attributes.
Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit 4b0c847f19d5db81758b5561bdc8196591209ef0)
Conflicts:
lib/puppet/type/file/source.rb
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/type/file/source_spec.rb | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/spec/unit/type/file/source_spec.rb b/spec/unit/type/file/source_spec.rb index 5129d1e01..c696feaf8 100755 --- a/spec/unit/type/file/source_spec.rb +++ b/spec/unit/type/file/source_spec.rb @@ -31,14 +31,6 @@ describe Puppet::Type.type(:file).attrclass(:source) do end end - it "should have a method for retrieving its metadata" do - source.new(:resource => @resource).must respond_to(:metadata) - end - - it "should have a method for setting its metadata" do - source.new(:resource => @resource).must respond_to(:metadata=) - end - describe "when returning the metadata", :fails_on_windows => true do before do @metadata = stub 'metadata', :source= => nil @@ -94,20 +86,6 @@ describe Puppet::Type.type(:file).attrclass(:source) do lambda { @source.metadata }.should raise_error(RuntimeError) end - - it "should expire the metadata appropriately" do - expirer = stub 'expired', :dependent_data_expired? => true - - metadata = stub 'metadata', :source= => nil - Puppet::FileServing::Metadata.indirection.expects(:find).with(@feebooz).returns metadata - - @source = source.new(:resource => @resource, :value => [@feebooz]) - @source.metadata = "foo" - - @source.stubs(:expirer).returns expirer - - @source.metadata.should_not == "foo" - end end it "should have a method for setting the desired values on the resource" do |