Skip to content
Snippets Groups Projects
Select Git revision
  • 1156b6f823e94c963cb0db7586cf56b801ea930f
  • master default protected
  • cleanup_fixtures
  • add-openvox
  • freebsd-14
  • remove-legacy-top-scope-syntax
  • rel430
  • tests
  • revert-363-augeas-module-cleanup
  • release-4.1.0
  • puppet8
  • relax-dependencies
  • rel400
  • mode
  • puppet7
  • release-3.1.0
  • freebsd13
  • freebsd11
  • stdlib
  • centos
  • fedora
  • v5.1.0
  • v5.0.0
  • v4.5.0
  • v4.4.0
  • v4.3.0
  • v4.2.1
  • v4.2.0
  • v4.1.0
  • v4.0.0
  • v3.1.0
  • v3.0.0
  • v2.0.0
  • 1.12.0
  • 1.11.0
  • 1.10.0
  • 1.9.0
  • 1.8.0
  • 1.7.0
  • 1.6.0
  • 1.5.0
41 results

main.cf

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    postfix_transport_spec.rb 3.89 KiB
    require 'spec_helper'
    
    describe 'postfix::transport' do
      let (:title) { 'foo' }
    
      let :pre_condition do
        "class { '::augeas': }"
      end
    
      on_supported_os.each do |os, facts|
        context "on #{os}" do
          let(:facts) do
            facts.merge({
              :augeasversion => '1.2.0',
              :puppetversion => Puppet.version,
            })
          end
    
          context 'when sending wrong type for destination' do
            let (:params) { {
              :destination => ['bar'],
            } }
    
            it 'should fail' do
              expect {
                is_expected.to contain_augeas('Postfix transport - foo')
              }.to raise_error
            end
          end
    
          context 'when sending wrong type for nexthop' do
            let (:params) { {
              :destination => 'bar',
              :nexthop     => ['baz'],
            } }
    
            it 'should fail' do
              expect {
                is_expected.to contain_augeas('Postfix transport - foo')
              }.to raise_error
            end
          end
    
          context 'when sending wrong type for file' do
            let (:params) { {
              :destination => 'bar',
              :file        => ['baz'],
            } }
    
            it 'should fail' do
              expect {
                is_expected.to contain_augeas('Postfix transport - foo')
              }.to raise_error
            end
          end
    
          context 'when sending wrong value for file' do
            let (:params) { {
              :destination => 'bar',
              :file        => 'baz',
            } }
    
            it 'should fail' do
              expect {
                is_expected.to contain_augeas('Postfix transport - foo')
              }.to raise_error(Puppet::Error, /, got /)
            end
          end
    
          context 'when sending wrong type for ensure' do
            let (:params) { {
              :destination => 'bar',
              :ensure      => ['baz'],
            } }
    
            it 'should fail' do
              expect {
                is_expected.to contain_augeas('Postfix transport - foo')
              }.to raise_error
            end
          end
    
          context 'when sending wrong value for ensure' do
            let (:params) { {
              :destination => 'bar',
              :ensure      => 'running',
            } }
    
            it 'should fail' do
              expect {
                is_expected.to contain_augeas('Postfix transport - foo')
              }.to raise_error(Puppet::Error, /got 'running'/)
            end
          end
    
          context 'when using default values' do
            it { is_expected.to contain_class('postfix::augeas') }
            it { is_expected.to contain_augeas('Postfix transport - foo').with(
              :incl    => '/etc/postfix/transport',
              :lens    => 'Postfix_Transport.lns',
              :changes => [
                "set pattern[. = 'foo'] 'foo'",
                "clear pattern[. = 'foo']/transport",
                "clear pattern[. = 'foo']/nexthop",
              ])
            }
          end
    
          context 'when overriding default values' do
            let (:params) { {
              :destination => 'bar',
              :nexthop     => 'baz',
              :file        => '/tmp/transport',
              :ensure      => 'present',
            } }
    
            it { is_expected.to contain_class('postfix::augeas') }
            it { is_expected.to contain_augeas('Postfix transport - foo').with(
              :incl    => '/tmp/transport',
              :lens    => 'Postfix_Transport.lns',
              :changes => [
                "set pattern[. = 'foo'] 'foo'",
                "set pattern[. = 'foo']/transport 'bar'",
                "set pattern[. = 'foo']/nexthop 'baz'",
              ])
            }
          end
    
          context 'when ensuring absence' do
            let (:params) { {
              :destination => 'bar',
              :ensure      => 'absent',
            } }
    
            it { is_expected.to contain_class('postfix::augeas') }
            it { is_expected.to contain_augeas('Postfix transport - foo').with(
              :incl    => '/etc/postfix/transport',
              :lens    => 'Postfix_Transport.lns',
              :changes => [
                "rm pattern[. = 'foo']",
              ])
            }
          end
        end
      end
    end