view modules/common/spec/defines/remove_if_empty_spec.rb @ 466:202aeef575a1

Correct HTTP log paths in LogWatch It wasn't generating logs because we're not using the normal pattern - our site name comes _after_ the "access" part, not before
author IBBoard <dev@ibboard.co.uk>
date Sun, 25 Feb 2024 10:10:32 +0000
parents 750d36241580
children
line wrap: on
line source

require 'spec_helper'

describe 'common::remove_if_empty' do
  context 'should create new directory' do
    let(:title) { '/some/dir/structure' }

    it {
      should contain_exec('remove_if_empty-/some/dir/structure').with({
        'command' => 'rm -f /some/dir/structure',
        'unless'  => 'test -f /some/dir/structure; if [ $? == \'0\' ]; then test -s /some/dir/structure; fi',
        'path'    => '/bin:/usr/bin:/sbin:/usr/sbin',
      })
    }
  end

  context 'should fail with a path that is not absolute' do
    let(:title) { 'not/a/valid/absolute/path' }

    it do
      expect {
        should contain_exec('remove_if_empty-not/a/valid/absolute/path')
      }.to raise_error(Puppet::Error)
    end
  end
end