Class: PuppetCatalogTest::Puppet4xAdapter

Inherits:
BasePuppetAdapter show all
Defined in:
lib/puppet-catalog-test/puppet_adapter/puppet_4x_adapter.rb

Instance Method Summary collapse

Methods inherited from BasePuppetAdapter

#cleanup, #init_config, #parser, #prepare

Constructor Details

#initialize(config) ⇒ Puppet4xAdapter

Returns a new instance of Puppet4xAdapter.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/puppet-catalog-test/puppet_adapter/puppet_4x_adapter.rb', line 5

def initialize(config)
  super(config)

  @env = Puppet.lookup(:current_environment).
    override_with(:manifest => config[:manifest_path]).
    override_with(:modulepath => config[:module_paths])

  @env.each_plugin_directory do |dir|
    $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
  end

  require 'puppet/test/test_helper'

  Puppet::Test::TestHelper.initialize
  Puppet::Test::TestHelper.before_all_tests
end

Instance Method Details

#compile(node) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/puppet-catalog-test/puppet_adapter/puppet_4x_adapter.rb', line 38

def compile(node)
  begin
    Puppet::Parser::Compiler.compile(node)
  rescue => e
    raise e
  ensure
    Puppet::Test::TestHelper.after_each_test
  end
end

#create_node(hostname, facts) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/puppet-catalog-test/puppet_adapter/puppet_4x_adapter.rb', line 30

def create_node(hostname, facts)
  Puppet::Test::TestHelper.before_each_test
  init_config
  node = Puppet::Node.new(hostname, :facts => Puppet::Node::Facts.new("facts", facts))
  node.merge(facts)
  node
end

#nodesObject



26
27
28
# File 'lib/puppet-catalog-test/puppet_adapter/puppet_4x_adapter.rb', line 26

def nodes
  @env.known_resource_types.nodes.keys
end

#versionObject



22
23
24
# File 'lib/puppet-catalog-test/puppet_adapter/puppet_4x_adapter.rb', line 22

def version
  Puppet.version
end