Skip to content
Snippets Groups Projects
Select Git revision
  • 431bbc990b7a7dbf23f7fc7afa10f0babd33e57b
  • master default protected
  • 5.x
  • ll-php8-bs5
  • release_5_bs5
  • ll-php8
  • 4.x
  • laminas_migration
  • release_1.0.0.2
  • release_4.0.0
  • release_3.2.8
  • bootstrap4_migration
  • 1.0.0.3
  • 6.0.7
  • 6.0.6
  • 6.0.5
  • 6.0.4
  • 6.0.3
  • 6.0.2
  • 6.0.1
  • 5.1.1
  • 6.0.0
  • 5.1.0
  • 5.0.0
  • 4.0.2
  • 3.2.11
  • 4.0.1
  • 3.2.10
  • 4.0.0
  • 1.0.0.2
  • 3.2.9
  • 3.2.8
32 results

AbstractFactoryTest.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    postfix_virtual_spec.rb 3.85 KiB
    require 'spec_helper'
    
    describe 'postfix::virtual' 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',
            })
          end
    
          context 'when not sending destination' do
            it 'should fail' do
              expect {
                is_expected.to contain_augeas('Postfix virtual - foo')
              }.to raise_error(Puppet::Error, /Must pass destination/)
            end
          end
    
          context 'when sending wrong type for destination' do
            let (:params) { {
              :destination => ['bar'],
            } }
    
            it 'should fail' do
              expect {
                is_expected.to contain_augeas('Postfix virtual - foo')
              }.to raise_error(Puppet::Error, /\["bar"\] is not a string/)
            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 virtual - foo')
              }.to raise_error(Puppet::Error, /\["baz"\] is not a string/)
            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 virtual - foo')
              }.to raise_error(Puppet::Error, /"baz" is not an absolute path/)
            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 virtual - foo')
              }.to raise_error(Puppet::Error, /\["baz"\] is not a string/)
            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 virtual - foo')
              }.to raise_error(Puppet::Error, /\$ensure must be either/)
            end
          end
    
          context 'when using default values' do
            let (:params) { {
              :destination => 'bar',
            } }
    
            it { is_expected.to contain_class('postfix::augeas') }
            it { is_expected.to contain_augeas('Postfix virtual - foo').with(
              :incl    => '/etc/postfix/virtual',
              :lens    => 'Postfix_Virtual.lns',
              :changes => [
                "set pattern[. = 'foo'] 'foo'",
                "set pattern[. = 'foo']/destination 'bar'",
              ])
            }
          end
    
          context 'when overriding default values' do
            let (:params) { {
              :destination => 'bar',
              :file        => '/tmp/virtual',
              :ensure      => 'present',
            } }
    
            it { is_expected.to contain_class('postfix::augeas') }
            it { is_expected.to contain_augeas('Postfix virtual - foo').with(
              :incl    => '/tmp/virtual',
              :lens    => 'Postfix_Virtual.lns',
              :changes => [
                "set pattern[. = 'foo'] 'foo'",
                "set pattern[. = 'foo']/destination 'bar'",
              ])
            }
          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 virtual - foo').with(
              :incl    => '/etc/postfix/virtual',
              :lens    => 'Postfix_Virtual.lns',
              :changes => [
                "rm pattern[. = 'foo']",
              ])
            }
          end
        end
      end
    end