Sha256: 11e59d8a9426235117ccb9f3a7ed4fe81c40f0d1a3bf16f4fc3f18b8f63f444e

Contents?: true

Size: 1.77 KB

Versions: 420

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'
require 'matchers/resource'
require 'puppet_spec/compiler'

describe "the realize function" do
  include Matchers::Resource
  include PuppetSpec::Compiler

  it "realizes a single, referenced resource" do
    catalog = compile_to_catalog(<<-EOM)
      @notify { testing: }
      realize(Notify[testing])
    EOM

    expect(catalog).to have_resource("Notify[testing]")
  end

  it "realizes multiple resources" do
    catalog = compile_to_catalog(<<-EOM)
      @notify { testing: }
      @notify { other: }
      realize(Notify[testing], Notify[other])
    EOM

    expect(catalog).to have_resource("Notify[testing]")
    expect(catalog).to have_resource("Notify[other]")
  end

  it "realizes resources provided in arrays" do
    catalog = compile_to_catalog(<<-EOM)
      @notify { testing: }
      @notify { other: }
      realize([Notify[testing], [Notify[other]]])
    EOM

    expect(catalog).to have_resource("Notify[testing]")
    expect(catalog).to have_resource("Notify[other]")
  end

  it "fails when the resource does not exist" do
    expect do
      compile_to_catalog(<<-EOM)
        realize(Notify[missing])
      EOM
    end.to raise_error(Puppet::Error, /Failed to realize/)
  end

  it "fails when no parameters given" do
    expect do
      compile_to_catalog(<<-EOM)
        realize()
      EOM
    end.to raise_error(Puppet::Error, /Wrong number of arguments/)
  end

  it "silently does nothing when an empty array of resources is given" do
    compile_to_catalog(<<-EOM)
      realize([])
    EOM
  end

  it 'is not available when --tasks is on' do
    Puppet[:tasks] = true
    expect do
      compile_to_catalog(<<-MANIFEST)
        realize([])
      MANIFEST
    end.to raise_error(Puppet::ParseError, /is only available when compiling a catalog/)
  end
end

Version data entries

420 entries across 420 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/parser/functions/realize_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-8.3.0-universal-darwin spec/unit/parser/functions/realize_spec.rb
puppet-8.4.0 spec/unit/parser/functions/realize_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-8.4.0-universal-darwin spec/unit/parser/functions/realize_spec.rb
puppet-7.28.0 spec/unit/parser/functions/realize_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-7.28.0-universal-darwin spec/unit/parser/functions/realize_spec.rb
puppet-8.3.1 spec/unit/parser/functions/realize_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-8.3.1-universal-darwin spec/unit/parser/functions/realize_spec.rb
puppet-7.27.0 spec/unit/parser/functions/realize_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-7.27.0-universal-darwin spec/unit/parser/functions/realize_spec.rb