diff options
| author | James Turnbull <james@lovedthanlost.net> | 2008-07-05 10:18:42 +1000 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-07-05 10:18:42 +1000 |
| commit | f4201a2b0a754ab6f276f4bf6e4fe7a976a1721e (patch) | |
| tree | 794f4a6377c63e6ac034a9dcd5d488718f371354 | |
| parent | 84b566590fe05e6c390127d8e85dca323dd949bd (diff) | |
| parent | 8865bdf112b33660a3e41b03f57d2575809e3cb4 (diff) | |
| download | puppet-f4201a2b0a754ab6f276f4bf6e4fe7a976a1721e.tar.gz puppet-f4201a2b0a754ab6f276f4bf6e4fe7a976a1721e.tar.xz puppet-f4201a2b0a754ab6f276f4bf6e4fe7a976a1721e.zip | |
Merge branch 'ticket/0.24.x/1067' of git://github.com/littleidea/puppet into 0.24.x
| -rwxr-xr-x | lib/puppet/type/file/ensure.rb | 5 | ||||
| -rwxr-xr-x | lib/puppet/type/file/source.rb | 20 | ||||
| -rwxr-xr-x | spec/unit/type/file.rb | 12 |
3 files changed, 19 insertions, 18 deletions
diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb index 0d2171216..a9ddc2dba 100755 --- a/lib/puppet/type/file/ensure.rb +++ b/lib/puppet/type/file/ensure.rb @@ -138,11 +138,6 @@ module Puppet # We have to treat :present specially, because it works with any # type of file. def insync?(currentvalue) - if property = @resource.property(:source) and ! property.described? - warning "No specified sources exist" - return true - end - if self.should == :present if currentvalue.nil? or currentvalue == :absent return false diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index 1b0dd3141..f2704abb6 100755 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -135,18 +135,8 @@ module Puppet return args end - # Have we successfully described the remote source? - def described? - ! @stats.nil? and ! @stats[:type].nil? #and @is != :notdescribed - end - # Use the info we get from describe() to check if we're in sync. def insync?(currentvalue) - unless described? - warning "No specified sources exist" - return true - end - if currentvalue == :nocopy return true end @@ -180,7 +170,11 @@ module Puppet def pinparams [:mode, :type, :owner, :group] end - + + def found? + ! (@stats.nil? or @stats[:type].nil?) + end + # This basically calls describe() on our file, and then sets all # of the local states appropriately. If the remote file is a normal # file then we set it to copy; if it's a directory, then we just mark @@ -202,8 +196,8 @@ module Puppet } end - if @stats.nil? or @stats[:type].nil? - return nil # :notdescribed + if !found? + raise Puppet::Error, "No specified source was found from" + @should.inject("") { |s, source| s + " #{source},"}.gsub(/,$/,"") end case @stats[:type] diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb index 12b806d88..f0ae70cd0 100755 --- a/spec/unit/type/file.rb +++ b/spec/unit/type/file.rb @@ -31,6 +31,18 @@ describe Puppet::Type.type(:file) do end end + describe "when specifying a source" do + before do + @file[:source] = "/bar" + end + + it "should raise if source doesn't exist" do + @file.property(:source).expects(:found?).returns(false) + lambda { @file.retrieve }.should raise_error(Puppet::Error) + end + + end + describe "when retrieving remote files" do before do @filesource = Puppet::Type::File::FileSource.new |
