Sha256: 9e458358cfc33941b9ab815ac1f66511a0038f2aeefc1b71ea9d9709912985ff

Contents?: true

Size: 1.34 KB

Versions: 57

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'
require 'puppet_spec/scope'

describe 'Puppet::Parser::Functions#hiera_include' do
  include PuppetSpec::Scope

  let :scope do create_test_scope_for_node('foo') end

  before :each do
    Puppet[:hiera_config] = PuppetSpec::Files.tmpfile('hiera_config')
  end

  it 'should require a key argument' do
    expect { scope.function_hiera_include([]) }.to raise_error(ArgumentError)
  end

  it 'should raise a useful error when nil is returned' do
    HieraPuppet.expects(:lookup).returns(nil)
    expect { scope.function_hiera_include(["badkey"]) }.
      to raise_error(Puppet::ParseError, /Could not find data item badkey/ )
  end

  it 'should use the array resolution_type' do
    HieraPuppet.expects(:lookup).with() { |*args| args[4].should be(:array) }.returns(['someclass'])
    expect { scope.function_hiera_include(['key']) }.to raise_error(Puppet::Error, /Could not find class someclass/)
  end

  it 'should call the `include` function with the classes' do
    HieraPuppet.expects(:lookup).returns %w[foo bar baz]

    scope.expects(:function_include).with([%w[foo bar baz]])
    scope.function_hiera_include(['key'])
  end

  it 'should not raise an error if the resulting hiera lookup returns an empty array' do
    HieraPuppet.expects(:lookup).returns []
    expect { scope.function_hiera_include(['key']) }.to_not raise_error
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
puppet-3.8.7 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.6 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.5 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.4 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.3 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.2 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.1 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/parser/functions/hiera_include_spec.rb