Skip to content

Commit 29a5059

Browse files
committed
(PUP-10942) Add cached loader get_conf tests
1 parent 0ad78cb commit 29a5059

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

spec/unit/environments_spec.rb

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,33 @@
617617
end
618618
end
619619

620+
context "#get_conf" do
621+
it "loads environment.conf" do
622+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
623+
expect(loader.get_conf(:an_environment)).to match_environment_conf(:an_environment).
624+
with_env_path(directory_tree.children.first).
625+
with_global_module_path([])
626+
end
627+
end
628+
629+
it "always reloads environment.conf" do
630+
env = Puppet::Node::Environment.create(:cached, [])
631+
mocked_loader = double('loader')
632+
expect(mocked_loader).to receive(:get_conf).with(:cached).and_return(Puppet::Settings::EnvironmentConf.static_for(env, 20)).twice
633+
634+
cached = Puppet::Environments::Cached.new(mocked_loader)
635+
636+
cached.get_conf(:cached)
637+
cached.get_conf(:cached)
638+
end
639+
640+
it "returns nil if environment is not found" do
641+
cached_loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
642+
expect(loader.get_conf(:doesnotexist)).to be_nil
643+
end
644+
end
645+
end
646+
620647
context "expiration policies" do
621648
let(:service) { ReplayExpirationService.new }
622649

@@ -694,14 +721,6 @@
694721
end
695722
end
696723

697-
it "gets an environment.conf" do
698-
loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
699-
expect(Puppet::Environments::Cached.new(loader).get_conf(:an_environment)).to match_environment_conf(:an_environment).
700-
with_env_path(directory_tree.children.first).
701-
with_global_module_path([])
702-
end
703-
end
704-
705724
context '#clear' do
706725
let(:service) { ReplayExpirationService.new }
707726

0 commit comments

Comments
 (0)