(14466) Warn when no facts found
Add `warnonce` message to Facter to alert user when no facts
were loaded.
Hailee Kenney
11 years ago
77 | 77 |
# Try HARDER
|
78 | 78 |
loader.load_all unless @facts[name]
|
79 | 79 |
|
|
80 |
# Warn if no facts were loaded
|
|
81 |
Facter.warnonce("No facts loaded from #{loader.search_path.join(File::PATH_SEPARATOR)}") if @facts.length == 0
|
|
82 |
|
80 | 83 |
@facts[name]
|
81 | 84 |
end
|
82 | 85 |
|
148 | 148 |
end
|
149 | 149 |
|
150 | 150 |
describe "when api connect test fails" do
|
|
151 |
before :each do
|
|
152 |
Facter.stubs(:warnonce)
|
|
153 |
end
|
|
154 |
|
151 | 155 |
it "should not populate ec2_userdata" do
|
152 | 156 |
# Emulate ec2 for now as it matters little to this test
|
153 | 157 |
Facter::Util::EC2.stubs(:has_euca_mac?).returns(true)
|
257 | 257 |
facts.should_not be_include("two")
|
258 | 258 |
end
|
259 | 259 |
end
|
|
260 |
|
|
261 |
describe "when no facts are loaded" do
|
|
262 |
before :each do
|
|
263 |
@coll = Facter::Util::Collection.new
|
|
264 |
@load = Facter::Util::Loader.new
|
|
265 |
@load.stubs(:load).returns nil
|
|
266 |
@load.stubs(:load_all).returns nil
|
|
267 |
@coll.stubs(:loader).returns @load
|
|
268 |
end
|
|
269 |
|
|
270 |
it "should warn when no facts were loaded" do
|
|
271 |
Facter.expects(:warnonce).with("No facts loaded from #{@load.search_path.join(File::PATH_SEPARATOR)}").once
|
|
272 |
@coll.fact("one")
|
|
273 |
end
|
|
274 |
end
|
260 | 275 |
end
|