File: kmod_option_spec.rb

package info (click to toggle)
puppet-module-voxpupuli-kmod 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 292 kB
  • sloc: ruby: 622; sh: 11; makefile: 10
file content (60 lines) | stat: -rw-r--r-- 1,581 bytes parent folder | download
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
58
59
60
# frozen_string_literal: true

require 'spec_helper'

describe 'kmod::option', type: :define do
  let(:title) { 'foo' }
  let(:default_params) do
    {
      'module' => 'bond0',
      'option' => 'mode',
      'value' => '1',
    }
  end

  on_supported_os.each do |os, os_facts|
    context "on #{os}" do
      let(:facts) { os_facts.merge(augeasversion: '1.2.0') }
      let(:params) { default_params }

      context 'when ensure is default (present)' do
        it { is_expected.to compile }
        it { is_expected.to contain_kmod__option(title).with(params) }

        it do
          is_expected.to contain_kmod__setting("kmod::option #{title}").
            with_ensure('present').
            with_module(params['module']).
            with_category('options').
            with_file("/etc/modprobe.d/#{params['module']}.conf").
            with_option(params['option']).
            with_value(params['value'])
        end
      end

      context 'when file permissions are specified' do
        let(:params) { default_params }
        let(:pre_condition) do
          <<~END
            class { 'kmod':
              owner     => 'adm',
              group     => 'sys',
              file_mode => '0600',
            }
          END
        end

        it { is_expected.to contain_kmod__option(title) }

        it {
          is_expected.to contain_file("/etc/modprobe.d/#{params['module']}.conf").
            with(
              'owner' => 'adm',
              'group' => 'sys',
              'mode' => '0600'
            )
        }
      end
    end
  end
end