Skip to content

Commit

Permalink
fixes #5522 - future parser can be set in puppet.conf [main]
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Cleal authored and ohadlevy committed May 8, 2014
1 parent b7d1b2b commit 8d3012f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/proxy/puppet/environment.rb
Expand Up @@ -125,7 +125,7 @@ def to_s
def classes
Initializer.load
conf = ConfigReader.new(Initializer.config).get
eparser = conf[:master] && conf[:master][:parser] == 'future'
eparser = (conf[:main] && conf[:main][:parser] == 'future') || (conf[:master] && conf[:master][:parser] == 'future')

paths.map {|path| PuppetClass.scan_directory path, eparser}.flatten
end
Expand Down
13 changes: 13 additions & 0 deletions test/puppet_class_test.rb
Expand Up @@ -28,4 +28,17 @@ def test_puppet_class_should_be_an_opject
klass = Proxy::Puppet::PuppetClass.new "foreman_proxy::install"
assert_kind_of Proxy::Puppet::PuppetClass, klass
end

def test_scan_directory_loads_scanner
Proxy::Puppet::Initializer.expects(:load)
Proxy::Puppet::ClassScanner.expects(:scan_directory).with('/foo')
Proxy::Puppet::PuppetClass.scan_directory('/foo', nil)
end

def test_scan_directory_loads_eparser_scanner
return unless Puppet::PUPPETVERSION.to_f >= 3.2
Proxy::Puppet::Initializer.expects(:load)
Proxy::Puppet::ClassScannerEParser.expects(:scan_directory).with('/foo')
Proxy::Puppet::PuppetClass.scan_directory('/foo', true)
end
end
24 changes: 24 additions & 0 deletions test/puppet_environment_test.rb
Expand Up @@ -38,6 +38,30 @@ def test_uses_puppet_config
Proxy::Puppet::Environment.send(:puppet_environments)
end

def test_classes_calls_scan_directory
Proxy::Puppet::ConfigReader.any_instance.stubs(:get).returns({})
env = Proxy::Puppet::Environment.new(:name => 'production', :paths => ['/etc/puppet/modules', '/etc/puppet/production'])
Proxy::Puppet::PuppetClass.expects(:scan_directory).with('/etc/puppet/modules', nil)
Proxy::Puppet::PuppetClass.expects(:scan_directory).with('/etc/puppet/production', nil)
env.classes
end

def test_classes_calls_scan_directory_with_eparser_master
Proxy::Puppet::ConfigReader.any_instance.stubs(:get).returns({:master => {:parser => 'future'}})
env = Proxy::Puppet::Environment.new(:name => 'production', :paths => ['/etc/puppet/modules', '/etc/puppet/production'])
Proxy::Puppet::PuppetClass.expects(:scan_directory).with('/etc/puppet/modules', true)
Proxy::Puppet::PuppetClass.expects(:scan_directory).with('/etc/puppet/production', true)
env.classes
end

def test_classes_calls_scan_directory_with_eparser_main
Proxy::Puppet::ConfigReader.any_instance.stubs(:get).returns({:main => {:parser => 'future'}})
env = Proxy::Puppet::Environment.new(:name => 'production', :paths => ['/etc/puppet/modules', '/etc/puppet/production'])
Proxy::Puppet::PuppetClass.expects(:scan_directory).with('/etc/puppet/modules', true)
Proxy::Puppet::PuppetClass.expects(:scan_directory).with('/etc/puppet/production', true)
env.classes
end

def test_single_static_env
config = {
:main => {},
Expand Down

0 comments on commit 8d3012f

Please sign in to comment.