summaryrefslogtreecommitdiff
path: root/spec/defines/munin_plugin_spec.rb
blob: 0e7306a9710704034eefe0597dd0202c1f8161f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'spec_helper'

describe 'munin::plugin' do
  let(:title) { 'users' }
  let(:facts) do
    { :operatingsystem => 'CentOS' }
  end
  context 'present' do
    it { should contain_file('/etc/munin/plugins/users').with(
      :ensure => 'link',
      :target => '/usr/share/munin/plugins/users'
    ) }
    it { should_not contain_file('/etc/munin/plugin-conf.d/users.conf') }
  end

  context 'present and config' do
    let(:params) do
      { :config => 'env.user root' }
    end
    it { should contain_file('/etc/munin/plugins/users').with(
      :ensure  => 'link',
      :target  => '/usr/share/munin/plugins/users',
      :notify  => 'Service[munin-node]'
    ) }
    it { should contain_file('/etc/munin/plugin-conf.d/users.conf').with(
      :content => "[users]\nenv.user root\n",
      :owner   => 'root',
      :group   => 0,
      :mode    => '0640'
    ) }
  end

  context 'present and config as an array' do
    let(:params) do
      { :config => [ 'env.user root', 'env.group root' ] }
    end
    it { should contain_file('/etc/munin/plugins/users').with(
      :ensure  => 'link',
      :target  => '/usr/share/munin/plugins/users',
      :notify  => 'Service[munin-node]'
    ) }
    it { should contain_file('/etc/munin/plugin-conf.d/users.conf').with(
      :content => "[users]\nenv.user root\nenv.group root\n",
      :owner   => 'root',
      :group   => 0,
      :mode    => '0640'
    ) }
  end

  context 'absent' do
    let(:params) do
      { :ensure => 'absent' }
    end
    it { should_not contain_file('/etc/munin/plugins/users') }
    it { should_not contain_file('/etc/munin/plugin-conf.d/users.conf') }
  end
end