aboutsummaryrefslogtreecommitdiff
path: root/spec/unit/provider
diff options
context:
space:
mode:
authorLuchian Nemes <luchian.nemes@puppet.com>2020-09-03 09:37:21 +0300
committerLuchian Nemes <luchian.nemes@puppet.com>2020-09-03 11:57:31 +0300
commit897ca7a86b9595761e1492a4ffa36bbdb751a15a (patch)
tree9ece0c496112da6826e135002fa181f4c0f15ef9 /spec/unit/provider
parente2512df5a3cf3113110f40a826970111097323bb (diff)
downloadpuppet-augeas_core-897ca7a86b9595761e1492a4ffa36bbdb751a15a.tar.gz
puppet-augeas_core-897ca7a86b9595761e1492a4ffa36bbdb751a15a.tar.bz2
(MODULES-7397) Load Augeas lenses from modules
When creating the load path for Augeas, the module directories are now also searched for lenses and their folder path is added accordingly. This happens in every context except `agent` application. Through plugin syncing (and later cached lenses) it does not need these extra paths.
Diffstat (limited to 'spec/unit/provider')
-rw-r--r--spec/unit/provider/augeas/augeas_spec.rb41
1 files changed, 34 insertions, 7 deletions
diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb
index 7c9336a..2d53933 100644
--- a/spec/unit/provider/augeas/augeas_spec.rb
+++ b/spec/unit/provider/augeas/augeas_spec.rb
@@ -1121,15 +1121,42 @@ describe Puppet::Type.type(:augeas).provider(:augeas) do
expect(provider.get_load_path(resource)).to eq('/foo:/bar:/baz')
end
- it 'offers pluginsync augeas/lenses subdir' do
- Puppet[:libdir] = my_fixture_dir
- expect(provider.get_load_path(resource)).to eq("#{my_fixture_dir}/augeas/lenses")
+ context 'when running application is agent' do
+ before(:each) do
+ Puppet[:libdir] = my_fixture_dir
+ Puppet::Application.stubs(:name).returns(:agent)
+ end
+
+ it 'offers pluginsync augeas/lenses subdir' do
+ expect(provider.get_load_path(resource)).to eq("#{my_fixture_dir}/augeas/lenses")
+ end
+
+ it 'offers both pluginsync and load_path paths' do
+ resource[:load_path] = ['/foo', '/bar', '/baz']
+ expect(provider.get_load_path(resource)).to eq("/foo:/bar:/baz:#{my_fixture_dir}/augeas/lenses")
+ end
end
- it 'offers both pluginsync and load_path paths' do
- Puppet[:libdir] = my_fixture_dir
- resource[:load_path] = ['/foo', '/bar', '/baz']
- expect(provider.get_load_path(resource)).to eq("/foo:/bar:/baz:#{my_fixture_dir}/augeas/lenses")
+ context 'when running application is not agent' do
+ before(:each) do
+ Puppet::Application.stubs(:name).returns(:apply)
+
+ env = Puppet::Node::Environment.create('root', ['/modules/foobar'])
+ Puppet.stubs(:lookup).returns(env)
+ env.stubs(:each_plugin_directory).yields('/modules/foobar')
+
+ resource[:load_path] = ['/foo', '/bar', '/baz']
+ end
+
+ it 'offers both load_path and module lenses path when available' do
+ File.stubs(:exist?).with('/modules/foobar/augeas/lenses').returns(true)
+ expect(provider.get_load_path(resource)).to eq('/foo:/bar:/baz:/modules/foobar/augeas/lenses')
+ end
+
+ it 'offers only load_path if module lenses path is not available' do
+ File.stubs(:exist?).with('/modules/foobar/augeas/lenses').returns(false)
+ expect(provider.get_load_path(resource)).to eq('/foo:/bar:/baz')
+ end
end
end
end