diff --git a/spec/unit/pops/evaluator/deferred_resolver_spec.rb b/spec/unit/pops/evaluator/deferred_resolver_spec.rb index d6c945facf8..7f7d7751a1c 100644 --- a/spec/unit/pops/evaluator/deferred_resolver_spec.rb +++ b/spec/unit/pops/evaluator/deferred_resolver_spec.rb @@ -7,37 +7,40 @@ let(:environment) { Puppet::Node::Environment.create(:testing, []) } let(:facts) { Puppet::Node::Facts.new('node.example.com') } + def compile_and_resolve_catalog(code, preprocess = false) + catalog = compile_to_catalog(code) + described_class.resolve_and_replace(facts, catalog, environment, preprocess) + catalog + end + it 'resolves deferred values in a catalog' do - catalog = compile_to_catalog(<<~END) + catalog = compile_and_resolve_catalog(<<~END, true) 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) + catalog = compile_and_resolve_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) + catalog = compile_and_resolve_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"])