Sha256: dd40b3999b2b2600095f6ae620398007d5b37faafb10f689be3ec5cbb70c149c

Contents?: true

Size: 1.4 KB

Versions: 72

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'
require 'puppet_spec/compiler'

describe Puppet::Pops::Evaluator::DeferredResolver do
  include PuppetSpec::Compiler

  let(:environment) { Puppet::Node::Environment.create(:testing, []) }
  let(:facts) { Puppet::Node::Facts.new('node.example.com') }

  it 'resolves deferred values in a catalog' do
    catalog = compile_to_catalog(<<~END)
      notify { "deferred":
        message => Deferred("join", [[1,2,3], ":"])
      }
    END
    described_class.resolve_and_replace(facts, catalog)

    expect(catalog.resource(:notify, 'deferred')[:message]).to eq('1:2:3')
  end

  it 'lazily resolves deferred values in a catalog' do
    catalog = compile_to_catalog(<<~END)
      notify { "deferred":
        message => Deferred("join", [[1,2,3], ":"])
      }
    END
    described_class.resolve_and_replace(facts, catalog, environment, false)

    deferred = catalog.resource(:notify, 'deferred')[:message]
    expect(deferred.resolve).to eq('1:2:3')
  end

  it 'lazily resolves nested deferred values in a catalog' do
    catalog = compile_to_catalog(<<~END)
      $args = Deferred("inline_epp", ["<%= 'a,b,c' %>"])
      notify { "deferred":
        message => Deferred("split", [$args, ","])
      }
    END
    described_class.resolve_and_replace(facts, catalog, environment, false)

    deferred = catalog.resource(:notify, 'deferred')[:message]
    expect(deferred.resolve).to eq(["a", "b", "c"])
  end

end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.3.0-universal-darwin spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.4.0 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.4.0-universal-darwin spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-7.28.0 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-7.28.0-universal-darwin spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.3.1 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-8.3.1-universal-darwin spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-7.27.0 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/pops/evaluator/deferred_resolver_spec.rb
puppet-7.27.0-universal-darwin spec/unit/pops/evaluator/deferred_resolver_spec.rb