summaryrefslogtreecommitdiffstats
path: root/spec/unit/util
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-05-16 00:08:35 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-05-20 18:29:04 +1000
commit138f19fc6e7bb1d8ebf305decaa045c53787297c (patch)
tree00cb8da45f0ff7b12fede738b7df9e045a1583a9 /spec/unit/util
parent415553e9485d7ba3ed867033ac9c3315107d3c92 (diff)
downloadpuppet-138f19fc6e7bb1d8ebf305decaa045c53787297c.tar.gz
puppet-138f19fc6e7bb1d8ebf305decaa045c53787297c.tar.xz
puppet-138f19fc6e7bb1d8ebf305decaa045c53787297c.zip
Caching whether named autoloaded files are missing
This is the big win, because it causes us to just skip the whole loading infrastructure, including skipping looking through the modulepath. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/util')
-rwxr-xr-xspec/unit/util/autoload.rb8
-rwxr-xr-xspec/unit/util/autoload/file_cache.rb24
2 files changed, 31 insertions, 1 deletions
diff --git a/spec/unit/util/autoload.rb b/spec/unit/util/autoload.rb
index 3bd5b50ad..d05bc15f0 100755
--- a/spec/unit/util/autoload.rb
+++ b/spec/unit/util/autoload.rb
@@ -71,11 +71,17 @@ describe Puppet::Util::Autoload do
end
it "should skip files that it knows are missing" do
- @autoload.expects(:missing_file?).returns true
+ @autoload.expects(:named_file_missing?).with("foo").returns true
@autoload.expects(:eachdir).never
@autoload.load("foo")
end
+
+ it "should register that files are missing if they cannot be found" do
+ @autoload.load("foo")
+
+ @autoload.should be_named_file_missing("foo")
+ end
end
describe "when loading all files" do
diff --git a/spec/unit/util/autoload/file_cache.rb b/spec/unit/util/autoload/file_cache.rb
index ad4e75f74..333ddb545 100755
--- a/spec/unit/util/autoload/file_cache.rb
+++ b/spec/unit/util/autoload/file_cache.rb
@@ -126,4 +126,28 @@ describe Puppet::Util::Autoload::FileCache do
other.should be_directory_exist("/my/file")
end
end
+
+ describe "when checking whether a named file exists" do
+ it "should have a method for testing whether a named file is missing" do
+ @cacher.should respond_to(:named_file_missing?)
+ end
+
+ it "should have a method for registering that a named file is missing" do
+ @cacher.should respond_to(:named_file_is_missing)
+ end
+
+ it "should cache that a file is missing for 15 seconds" do
+ now = Time.now
+
+ later = now + 16
+
+ Time.expects(:now).times(2).returns(now).then.returns(later)
+ @cacher.named_file_is_missing("foo")
+ @cacher.should_not be_named_file_missing("foo")
+ end
+
+ it "should return false when registering a file as missing" do
+ @cacher.named_file_is_missing("foo").should be_false
+ end
+ end
end