postfix_spec.rb 1.03 KB
Newer Older
Mickaël Canévet's avatar
Mickaël Canévet committed
1
2
3
4
5
6
7
require 'spec_helper_acceptance'

describe 'postfix class' do

  context 'default parameters' do
    it 'should work idempotently with no errors' do
      pp = <<-EOS
Raphaël Pinson's avatar
Raphaël Pinson committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
        # Make sure the default mailer is stopped in docker containers
        if $::operatingsystem == 'Debian' {
          service { 'exim4':
            ensure    => stopped,
            hasstatus => false,
            before    => Class['postfix'],
          }
        }
        if $::osfamily == 'RedHat' {
          service { 'sendmail':
            ensure    => stopped,
            hasstatus => false,
            before    => Class['postfix'],
          }
        }

Mickaël Canévet's avatar
Mickaël Canévet committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
        class { 'postfix': }
      EOS

      # Run it twice and test for idempotency
      apply_manifest(pp, :catch_failures => true)
      apply_manifest(pp, :catch_changes  => true)
    end

    describe package('postfix') do
      it { is_expected.to be_installed }
    end

    describe service('postfix') do
      it { is_expected.to be_enabled }
      it { is_expected.to be_running }
    end
  end
end