[Pkg-puppet-devel] [facter] 70/352: (#22944) Reload external facts after the collection is flushed
Stig Sandbeck Mathisen
ssm at debian.org
Sun Apr 6 22:21:32 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit c4090f7de6b96f11ad295e7cba5d7d55132dd342
Author: Josh Cooper <josh at puppetlabs.com>
Date: Fri Dec 6 11:25:01 2013 -0800
(#22944) Reload external facts after the collection is flushed
Previously, external facts were not reloaded after
`Facter::Util::Collection#flush` was called, which doesn't match the
semantics of the `flush` method.
This commit ensures we are capable of reloading external facts after
`flush` is called.
Note that this isn't an issue when `Facter.clear` is called, because
that discards the collection entirely, so external facts will be
reloaded if necessary.
---
lib/facter/util/collection.rb | 1 +
spec/unit/util/collection_spec.rb | 18 +++++++++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/facter/util/collection.rb b/lib/facter/util/collection.rb
index 4b91e10..63233cb 100644
--- a/lib/facter/util/collection.rb
+++ b/lib/facter/util/collection.rb
@@ -96,6 +96,7 @@ class Facter::Util::Collection
# Flush all cached values.
def flush
@facts.each { |name, fact| fact.flush }
+ @external_facts_loaded = nil
end
# Return a list of all of the facts.
diff --git a/spec/unit/util/collection_spec.rb b/spec/unit/util/collection_spec.rb
index 1c92cf2..6e20d26 100755
--- a/spec/unit/util/collection_spec.rb
+++ b/spec/unit/util/collection_spec.rb
@@ -209,7 +209,8 @@ describe Facter::Util::Collection do
end
describe "external facts" do
- let(:collection) { Facter::Util::Collection.new(internal_loader, SingleFactLoader.new(:test_fact, "fact value")) }
+ let(:external_loader) { SingleFactLoader.new(:test_fact, "fact value") }
+ let(:collection) { Facter::Util::Collection.new(internal_loader, external_loader) }
it "loads when a specific fact is requested" do
collection.fact(:test_fact).value.should == "fact value"
@@ -225,6 +226,21 @@ describe Facter::Util::Collection do
facts.should == [["test_fact", "fact value"]]
end
+
+ it "are loaded only once" do
+ external_loader.expects(:load).with(collection)
+
+ collection.load_all
+ collection.load_all
+ end
+
+ it "are reloaded after flushing" do
+ external_loader.expects(:load).with(collection).twice
+
+ collection.load_all
+ collection.flush
+ collection.load_all
+ end
end
class SingleFactLoader
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list