Sha256: 1f112e836d2c848de92c938b780b7f46bdd1ebc023fe2905b9e3d6f907d41f97

Contents?: true

Size: 1.68 KB

Versions: 36

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

describe Puppet::Type.type(:mailalias) do
  include PuppetSpec::Files

  let :tmpfile_path do tmpfile('afile') end
  let :target do tmpfile('mailalias') end
  let :recipient_resource do
    described_class.new(:name => "luke", :recipient => "yay", :target => target)
  end

  let :file_resource do
    described_class.new(:name => "lukefile", :file => tmpfile_path, :target => target)
  end

  it "should be initially absent as a recipient" do
    expect(recipient_resource.retrieve_resource[:recipient]).to eq(:absent)
  end

  it "should be initially absent as an included file" do
    expect(file_resource.retrieve_resource[:file]).to eq(:absent)
  end

  it "should try and set the recipient when it does the sync" do
    expect(recipient_resource.retrieve_resource[:recipient]).to eq(:absent)
    expect(recipient_resource.property(:recipient)).to receive(:set).with(["yay"])
    recipient_resource.property(:recipient).sync
  end

  it "should try and set the included file when it does the sync" do
    expect(file_resource.retrieve_resource[:file]).to eq(:absent)
    expect(file_resource.property(:file)).to receive(:set).with(tmpfile_path)
    file_resource.property(:file).sync
  end

  it "should fail when file is not an absolute path" do
    expect {
      Puppet::Type.type(:mailalias).new(:name => 'x', :file => 'afile')
    }.to raise_error Puppet::Error, /File paths must be fully qualified/
  end

  it "should fail when both file and recipient are specified" do
    expect {
      Puppet::Type.type(:mailalias).new(:name => 'x', :file => tmpfile_path,
					:recipient => 'foo@example.com')
    }.to raise_error Puppet::Error, /cannot specify both a recipient and a file/
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
puppet-5.5.22 spec/unit/type/mailalias_spec.rb
puppet-5.5.22-x86-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.22-x64-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.22-universal-darwin spec/unit/type/mailalias_spec.rb
puppet-5.5.21 spec/unit/type/mailalias_spec.rb
puppet-5.5.21-x86-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.21-x64-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.21-universal-darwin spec/unit/type/mailalias_spec.rb
puppet-5.5.20 spec/unit/type/mailalias_spec.rb
puppet-5.5.20-x86-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.20-x64-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.20-universal-darwin spec/unit/type/mailalias_spec.rb
puppet-5.5.19 spec/unit/type/mailalias_spec.rb
puppet-5.5.19-x86-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.19-x64-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.19-universal-darwin spec/unit/type/mailalias_spec.rb
puppet-5.5.18 spec/unit/type/mailalias_spec.rb
puppet-5.5.18-x86-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.18-x64-mingw32 spec/unit/type/mailalias_spec.rb
puppet-5.5.18-universal-darwin spec/unit/type/mailalias_spec.rb