Skip to content
Snippets Groups Projects
Select Git revision
  • de2862b107a0f0e2a9953f83eeb60b2734b8026e
  • master default protected
  • b24
  • ll-workflow
  • alc-scindage-donnees-pj
  • FJ_LL_Tbl_Contrat
  • alc-docker-node
  • ll-apiplatform
  • php84
  • ll-rgpd
  • b23
  • alc-filtre-type-intervenant
  • ll-sans-mdb5
  • formules-ancienne-infra
  • ll-formules
  • alc-intervenant-dmep
  • ll-suppr-v_vol-s
  • b20
  • ll-postgresql
  • b23.0.1
  • b22
  • 24.8
  • 24.7
  • 24.6
  • 24.5
  • 24.4
  • 24.3
  • 24.2
  • 24.1
  • 24.0
  • 23.15
  • 24.0-beta19
  • 24.0-beta18
  • 24.0-beta17
  • 24.0-beta16
  • 24.0-beta15
  • 24.0-beta14
  • 24.0-beta13
  • 23.14
  • 24.0-beta12
  • 24.0-beta11
41 results

test2.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