Commit e81564f0 authored by Mickaël Canévet's avatar Mickaël Canévet
Browse files

Manage unit tests with rspec-puppet-facts

parent 745509f3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@
      "operatingsystem": "RedHat",
      "operatingsystemrelease": [
        "5",
        "6"
        "6",
        "7"
      ]
    }
  ],
+19 −14
Original line number Diff line number Diff line
require 'spec_helper'

describe 'postfix::augeas' do
  let (:facts) { {
    :augeasversion   => '1.2.0',
    :lsbdistcodename => 'wheezy',
    :operatingsystem => 'Debian',
    :osfamily        => 'Debian',
    :rubyversion     => '1.9.3',
    :path            => '/foo/bar',
  } }

  let :pre_condition do
    "include ::augeas"
  end

  it { is_expected.to contain_augeas__lens('postfix_transport').with(
  on_supported_os.each do |os, facts|
    context "on #{os}" do
      let(:facts) do
        facts.merge({
          :augeasversion => '1.2.0',
        })
      end

      it { is_expected.to compile.with_all_deps }

      it { is_expected.to contain_augeas__lens('postfix_transport').with({
        :ensure      => 'present',
        :lens_source => 'puppet:///modules/postfix/lenses/postfix_transport.aug',
        :test_source => 'puppet:///modules/postfix/lenses/test_postfix_transport.aug',
    :stock_since => '1.0.0'
  ) }
  it { is_expected.to contain_augeas__lens('postfix_virtual').with(
        :stock_since => '1.0.0',
      } ) }
      it { is_expected.to contain_augeas__lens('postfix_virtual').with({
        :ensure      => 'present',
        :lens_source => 'puppet:///modules/postfix/lenses/postfix_virtual.aug',
        :test_source => 'puppet:///modules/postfix/lenses/test_postfix_virtual.aug',
    :stock_since => '1.0.0'
  ) }
        :stock_since => '1.0.0',
      }) }
    end
  end
end
+14 −0
Original line number Diff line number Diff line
require 'spec_helper'

describe 'postfix::mailman' do

  let :pre_condition do
    "include ::postfix"
  end

  on_supported_os.each do |os, facts|
    context "on #{os}" do
      let(:facts) do
        facts
      end

      it { is_expected.to compile.with_all_deps }
    end
  end
end
+9 −5
Original line number Diff line number Diff line
require 'spec_helper'

describe 'postfix::mta' do
  let (:facts) { {
    :lsbdistcodename => 'wheezy',
    :osfamily        => 'Debian',
    :path            => '/foo/bar',
  } }
  let :pre_condition do
    "class { 'postfix':
      mydestination => 'bar',
@@ -14,7 +9,16 @@ describe 'postfix::mta' do
    }"
  end

  on_supported_os.each do |os, facts|
    context "on #{os}" do
      let(:facts) do
        facts
      end

      it { is_expected.to compile.with_all_deps }
      it { is_expected.to contain_postfix__config('mydestination').with_value('bar') }
      it { is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.1/8, [::1]/128 ![::2]/128') }
      it { is_expected.to contain_postfix__config('relayhost').with_value('foo') }
    end
  end
end
+12 −8
Original line number Diff line number Diff line
require 'spec_helper'

describe 'postfix::satellite' do
  let (:node) { 'foo.example.com' }
  let (:facts) { {
    :augeasversion   => '1.2.0',
    :lsbdistcodename => 'wheezy',
    :osfamily        => 'Debian',
    :rubyversion     => '1.9.3',
    :path            => '/foo/bar',
  } }
  let :pre_condition do
    " class { 'augeas': }
    class { 'postfix':
@@ -17,9 +9,21 @@ describe 'postfix::satellite' do
      mynetworks    => 'baz',
    }"
  end

  on_supported_os.each do |os, facts|
    context "on #{os}" do
      let(:facts) do
        facts.merge({
          :augeasversion => '1.2.0',
        })
      end

      it { is_expected.to compile.with_all_deps }
      it { is_expected.to contain_class('postfix::mta') }
      it { is_expected.to contain_postfix__virtual('@foo.example.com').with(
        :ensure      => 'present',
        :destination => 'root'
      ) }
    end
  end
end
Loading