Commit 72255416 authored by Tim 'bastelfreak' Meusel's avatar Tim 'bastelfreak' Meusel
Browse files

postfix:canonical: Add unit tests

parent d9321927
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -643,17 +643,16 @@ This type manages content of the /etc/postfix/canonical map.
# - Postfix::Hash["/etc/postfix/canonical"]
# - Postfix::Config["canonical_maps"] or Postfix::Config["sender_canonical_maps"] or Postfix::Config["recipient_canonical_maps"]
include postfix
postfix::hash { "/etc/postfix/recipient_canonical":
postfix::hash { '/etc/postfix/recipient_canonical':
  ensure => present,
}
postfix::config { "canonical_alias_maps":
  value => "hash:/etc/postfix/recipient_canonical"
postfix::config { 'canonical_alias_maps':
  value => 'hash:/etc/postfix/recipient_canonical',
}
postfix::canonical {
  "user@example.com":
    file        => "/etc/postfix/recipient_canonical",
postfix::canonical { 'user@example.com':
  file        => '/etc/postfix/recipient_canonical',
  ensure      => present,
    destination => "root";
  destination => 'root',
}
```

+7 −8
Original line number Diff line number Diff line
@@ -8,17 +8,16 @@
#   # - Postfix::Hash["/etc/postfix/canonical"]
#   # - Postfix::Config["canonical_maps"] or Postfix::Config["sender_canonical_maps"] or Postfix::Config["recipient_canonical_maps"]
#   include postfix
#   postfix::hash { "/etc/postfix/recipient_canonical":
#   postfix::hash { '/etc/postfix/recipient_canonical':
#     ensure => present,
#   }
#   postfix::config { "canonical_alias_maps":
#     value => "hash:/etc/postfix/recipient_canonical"
#   postfix::config { 'canonical_alias_maps':
#     value => 'hash:/etc/postfix/recipient_canonical',
#   }
#   postfix::canonical {
#     "user@example.com":
#       file        => "/etc/postfix/recipient_canonical",
#   postfix::canonical { 'user@example.com':
#     file        => '/etc/postfix/recipient_canonical',
#     ensure      => present,
#       destination => "root";
#     destination => 'root',
#   }
#
# @param ensure
+40 −0
Original line number Diff line number Diff line
# frozen_string_literal: true

require 'spec_helper'

describe 'postfix::canonical' do
  let(:title) { 'foo@example.com' }

  on_supported_os.each do |os, os_facts|
    context "on #{os}" do
      let(:facts) do
        os_facts
      end
      let(:params) do
        {
          ensure: 'present',
          file: '/etc/postfix/recipient_canonical',
          destination: 'root',
        }
      end

      context 'without related postfix::map resource' do
        it { is_expected.not_to compile.with_all_deps }
      end

      context 'with related postfix::map resource' do
        let :pre_condition do
          <<-PUPPET
          postfix::config { 'canonical_alias_maps':
           value => 'hash:/etc/postfix/recipient_canonical',
          }
          postfix::hash { '/etc/postfix/recipient_canonical':
          }
          PUPPET
        end

        it { is_expected.to compile.with_all_deps }
      end
    end
  end
end