summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-02-18 17:13:10 -0600
committerLuke Kanies <luke@madstop.com>2008-02-18 17:13:10 -0600
commit60dd5692715bf38226db2d46eb6b93e18a72eb00 (patch)
tree4e6105813d60b01b2a69dbff1175c33a13f6ed91 /spec
parentd11cd39024e1baa5988e587e34fad65bb116ea01 (diff)
Fixed #1037 -- remote unreadable files no longer have the
permission denied exceptions caught, thus forbidding them from being replaced with 'nil'.
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/ral/types/file.rb55
1 files changed, 44 insertions, 11 deletions
diff --git a/spec/unit/ral/types/file.rb b/spec/unit/ral/types/file.rb
index 7202e23e5..9ff6dc977 100755
--- a/spec/unit/ral/types/file.rb
+++ b/spec/unit/ral/types/file.rb
@@ -4,26 +4,59 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/type/file'
-describe Puppet::Type::File, " when used with replace=>false and content" do
+describe Puppet::Type::File do
before do
@path = Tempfile.new("puppetspec")
@path.close!()
@path = @path.path
- @file = Puppet::Type::File.create( { :name => @path, :content => "foo", :replace => :false } )
+ @file = Puppet::Type::File.create(:name => @path)
end
- it "should be insync if the file exists and the content is different" do
- File.open(@path, "w") do |f| f.puts "bar" end
- @file.property(:content).insync?("bar").should be_true
- end
+ describe "when used with content and replace=>false" do
+ before do
+ @file[:content] = "foo"
+ @file[:replace] = false
+ end
+
+ it "should be insync if the file exists and the content is different" do
+ File.open(@path, "w") do |f| f.puts "bar" end
+ @file.property(:content).insync?("bar").should be_true
+ end
- it "should be insync if the file exists and the content is right" do
- File.open(@path, "w") do |f| f.puts "foo" end
- @file.property(:content).insync?("foo").should be_true
+ it "should be insync if the file exists and the content is right" do
+ File.open(@path, "w") do |f| f.puts "foo" end
+ @file.property(:content).insync?("foo").should be_true
+ end
+
+ it "should not be insync if the file does not exist" do
+ @file.property(:content).insync?(:nil).should be_false
+ end
end
- it "should not be insync if the file doesnot exist" do
- @file.property(:content).insync?(:nil).should be_false
+ describe "when retrieving remote files" do
+ before do
+ @filesource = Puppet::Type::File::FileSource.new
+ @filesource.server = mock 'fileserver'
+
+ @file.stubs(:uri2obj).returns(@filesource)
+
+ @file[:source] = "puppet:///test"
+ end
+
+ it "should fail without writing if it cannot retrieve remote contents" do
+ # create the file, because we only get the problem when it starts
+ # out absent.
+ File.open(@file[:path], "w") { |f| f.puts "a" }
+ Puppet::Util::Log.level = :debug
+ Puppet::Util::Log.newdestination :console
+ @file.expects(:write).never
+
+
+ @filesource.server.stubs(:describe).returns("493\tfile\t100\t0\t{md5}3f5fef3bddbc4398c46a7bd7ba7b3af7")
+ @filesource.server.stubs(:retrieve).raises(RuntimeError)
+ @file.property(:source).retrieve
+ lambda { @file.property(:source).sync }.should raise_error(Puppet::Error)
+ end
end
after do