require_relative '../../../../spec_helper'

describe 'govuk::node::s_whitehall_backend', :type => :class do
  let(:node) { 'whitehall-backend-1.backend.somethingsomething' }
  let(:hiera_data) {{
    'app_domain'            => 'giraffe.biz',
    'asset_root'            => 'https://static.test.gov.uk',
    'website_root'          => 'www.giraffe.biz',
  }}
  context 'sync_mirror is true' do
    let(:params) {{ :sync_mirror => true }}
    it { should contain_file('/var/lib/govuk_mirror').with(
      :ensure  => 'directory',
      :owner   => 'deploy',
      :group   => 'deploy',
      :mode    => '0770',
    )}
    it { should contain_file('/var/lib/govuk_mirror/current').with(
      :ensure  => 'directory',
      :owner   => 'deploy',
      :group   => 'deploy',
      :mode    => '0770'
    ).that_requires('File[/var/lib/govuk_mirror]') }
  end

  context 'defaults' do
    let(:params) {{ }}
    it { should_not contain_file('/var/lib/govuk_mirror') }
    it { should_not contain_file('/var/lib/govuk_mirror/current') }
  end
end

require_relative '../../../../spec_helper'

describe 'govuk::node::s_whitehall_backend', :type => :class do
  let(:node) { 'whitehall-backend-1.backend.somethingsomething' }
  let(:hiera_data) {{
    'app_domain'            => 'giraffe.biz',
    'asset_root'            => 'https://static.test.gov.uk',
    'website_root'          => 'www.giraffe.biz',
  }}
  let(:facts) {{ :concat_basedir => '/var/lib/puppet/concat/'}}
  context 'sync_mirror is true' do
    let(:params) {{ :sync_mirror => true }}
    it { should contain_file('/var/lib/govuk_mirror').with(
      :ensure  => 'directory',
      :owner   => 'deploy',
      :group   => 'deploy',
      :mode    => '0770',
    )}
    it { should contain_file('/var/lib/govuk_mirror/current').with(
      :ensure  => 'directory',
      :owner   => 'deploy',
      :group   => 'deploy',
      :mode    => '0770'
    ).that_requires('File[/var/lib/govuk_mirror]') }
  end

  context 'defaults' do
    let(:params) {{ }}
    it { should_not contain_file('/var/lib/govuk_mirror') }
    it { should_not contain_file('/var/lib/govuk_mirror/current') }
  end
end

Fix spec s_whitehall_backend on non-puppetised machines
Fix spec s_whitehall_backend on non-puppetised machines

Because this node includes the mirror, which uses the concat module,
there will be a test failure if you run the specs on your mac rather
than on a linux machine which has the concat module and it's facts
installed.

This deliberately sets concat_basedir in the spec (as per s_monitoring
spec) to stop the test failure.
