summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-08-07 17:39:44 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-08-10 17:36:17 +1000
commit0cb9072c0e3b37332f4eeaeff061950d6f73d021 (patch)
treebb813907b006c28601117fc939887cd437a21485 /spec
parent23948d0b7efb482f891a333d4af56dc5ac59c00f (diff)
Fixing #2541 - file cache is more resilient to failure
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/util/autoload/file_cache.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/unit/util/autoload/file_cache.rb b/spec/unit/util/autoload/file_cache.rb
index 333ddb545..59620ed2d 100755
--- a/spec/unit/util/autoload/file_cache.rb
+++ b/spec/unit/util/autoload/file_cache.rb
@@ -31,6 +31,21 @@ describe Puppet::Util::Autoload::FileCache do
@cacher.should_not be_file_exist("/my/file")
end
+ it "should consider a file as absent if the directory is absent" do
+ File.expects(:lstat).with("/my/file").raises Errno::ENOTDIR
+ @cacher.should_not be_file_exist("/my/file")
+ end
+
+ it "should consider a file as absent permissions are missing" do
+ File.expects(:lstat).with("/my/file").raises Errno::EACCES
+ @cacher.should_not be_file_exist("/my/file")
+ end
+
+ it "should raise non-fs exceptions" do
+ File.expects(:lstat).with("/my/file").raises ArgumentError
+ lambda { @cacher.file_exist?("/my/file") }.should raise_error(ArgumentError)
+ end
+
it "should consider a file as present if its lstat succeeds" do
File.expects(:lstat).with("/my/file").returns mock("stat")
@cacher.should be_file_exist("/my/file")
@@ -87,6 +102,21 @@ describe Puppet::Util::Autoload::FileCache do
@cacher.should_not be_directory_exist("/my/file")
end
+ it "should consider a file as absent if the directory is absent" do
+ File.expects(:lstat).with("/my/file").raises Errno::ENOTDIR
+ @cacher.should_not be_directory_exist("/my/file")
+ end
+
+ it "should consider a file as absent permissions are missing" do
+ File.expects(:lstat).with("/my/file").raises Errno::EACCES
+ @cacher.should_not be_directory_exist("/my/file")
+ end
+
+ it "should raise non-fs exceptions" do
+ File.expects(:lstat).with("/my/file").raises ArgumentError
+ lambda { @cacher.directory_exist?("/my/file") }.should raise_error(ArgumentError)
+ end
+
it "should consider a directory as present if its lstat succeeds and the stat is of a directory" do
@stat.expects(:directory?).returns true
File.expects(:lstat).with("/my/file").returns @stat