require 'spec_helper'

# This function is called inside the OS specific conte, :compilexts
def general_mime_specs
  it { is_expected.to contain_apache__mod('mime') }

  it do
    is_expected.to contain_file('mime.conf').with_content(%r{AddHandler type-map var})
    is_expected.to contain_file('mime.conf').with_content(%r{ddOutputFilter INCLUDES .shtml})
    is_expected.to contain_file('mime.conf').with_content(%r{AddType text/html .shtml})
    is_expected.to contain_file('mime.conf').with_content(%r{AddType application/x-compress .Z})
  end
end

describe 'apache::mod::mime', type: :class do
  it_behaves_like 'a mod class, without including apache'

  context 'On a Debian OS with default params', :compile do
    let :facts do
      {
        osfamily: 'Debian',
        operatingsystemrelease: '8',
        lsbdistcodename: 'jessie',
        operatingsystem: 'Debian',
        id: 'root',
        kernel: 'Linux',
        path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
        is_pe: false,
      }
    end

    general_mime_specs

    it { is_expected.to contain_file('mime.conf').with_path('/etc/apache2/mods-available/mime.conf') }
  end

  context 'on a RedHat OS with default params', :compile do
    let :facts do
      {
        osfamily: 'RedHat',
        operatingsystemrelease: '6',
        operatingsystem: 'RedHat',
        id: 'root',
        kernel: 'Linux',
        path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
        is_pe: false,
      }
    end

    general_mime_specs

    it { is_expected.to contain_file('mime.conf').with_path('/etc/httpd/conf.d/mime.conf') }
  end
end
