|
6 | 6 | on_supported_os.each do |os, facts| |
7 | 7 | context "on #{os}" do |
8 | 8 | let(:facts) do |
9 | | - facts.merge(os: { family: facts['osfamily'] }) |
| 9 | + facts |
10 | 10 | end |
11 | 11 | let(:params) do |
12 | 12 | { javahome: '/opt/java' } |
|
15 | 15 | 'package { "jdk": }' |
16 | 16 | end |
17 | 17 |
|
18 | | - if os == 'RedHat' |
19 | | - context 'default params' do |
20 | | - it { is_expected.to contain_service('jira') } |
21 | | - it { is_expected.to compile.with_all_deps } |
22 | | - it do |
23 | | - is_expected.to contain_file('/etc/init.d/jira'). |
24 | | - with_content(%r{Short-Description: Start up JIRA}). |
25 | | - with_content(%r{lockfile=/var/lock/subsys/jira}) |
26 | | - end |
| 18 | + case facts[:os]['family'] |
| 19 | + when 'RedHat' |
| 20 | + service_file_location = if facts['service_provider'] == 'systemd' |
| 21 | + '/usr/lib/systemd/system/jira.service' |
| 22 | + else |
| 23 | + '/etc/init.d/jira' |
| 24 | + end |
| 25 | + when 'Debian' |
| 26 | + service_file_location = '/lib/systemd/system/jira.service' |
| 27 | + end |
| 28 | + |
| 29 | + context 'with defaults for all parameters' do |
| 30 | + it { is_expected.to compile.with_all_deps } |
| 31 | + |
| 32 | + case facts['service_provider'] |
| 33 | + when 'systemd' |
27 | 34 | it do |
28 | | - is_expected.not_to contain_file('/usr/lib/systemd/system/jira.service'). |
| 35 | + is_expected.to contain_file(service_file_location). |
29 | 36 | with_content(%r{Atlassian Systemd Jira Service}) |
30 | 37 | end |
31 | | - it { is_expected.not_to contain_exec('refresh_systemd') } |
32 | | - end |
33 | | - end |
34 | | - if os == 'Debian' |
35 | | - context 'lockfile on Debian' do |
36 | | - it { is_expected.to compile.with_all_deps } |
| 38 | + it { is_expected.to contain_exec('refresh_systemd') } |
| 39 | + when 'redhat' |
37 | 40 | it do |
38 | | - is_expected.to contain_file('/etc/init.d/jira'). |
39 | | - with_content(%r{/var/lock/jira}) |
| 41 | + is_expected.to contain_file(service_file_location). |
| 42 | + with_content(%r{Short-Description: Start up JIRA}). |
| 43 | + with_content(%r{lockfile=/var/lock/subsys/jira}) |
40 | 44 | end |
41 | 45 | end |
42 | | - end |
43 | | - if os =~ %r{ubuntu} |
44 | | - context 'default params' do |
45 | | - it { is_expected.to compile.with_all_deps } |
46 | | - end |
47 | | - end |
48 | | - if os =~ %r{ubuntu-16} |
49 | | - context 'default params' do |
50 | | - let(:facts) do |
51 | | - facts.merge(operatingsystem: 'Ubuntu', operatingsystemmajrelease: '16.04') |
52 | | - end |
53 | 46 |
|
54 | | - it { is_expected.to contain_file('/lib/systemd/system/jira.service') } |
55 | | - end |
| 47 | + it { is_expected.to contain_service('jira') } |
56 | 48 | end |
57 | | - context 'overwriting service_manage param' do |
| 49 | + |
| 50 | + context 'with service_manage set to false' do |
58 | 51 | let(:params) do |
59 | 52 | super().merge(service_manage: false) |
60 | 53 | end |
61 | 54 |
|
62 | 55 | it { is_expected.not_to contain_service('jira') } |
63 | 56 | end |
64 | | - context 'overwriting service params' do |
| 57 | + context 'with service_ensure set to stopped' do |
65 | 58 | let(:params) do |
66 | 59 | super().merge( |
67 | 60 | service_ensure: 'stopped', |
|
77 | 70 | 'subscribe' => 'Package[jdk]') |
78 | 71 | end |
79 | 72 | end |
80 | | - context 'RedHat/CentOS 7 systemd init script' do |
81 | | - let(:facts) do |
82 | | - { |
83 | | - osfamily: 'RedHat', |
84 | | - operatingsystemmajrelease: '7', |
85 | | - os: { family: 'RedHat' } |
86 | | - } |
87 | | - end |
88 | | - |
89 | | - it do |
90 | | - is_expected.to contain_file('/usr/lib/systemd/system/jira.service'). |
91 | | - with_content(%r{Atlassian Systemd Jira Service}) |
92 | | - end |
93 | | - it { is_expected.to contain_exec('refresh_systemd') } |
94 | | - end |
95 | 73 | end |
96 | 74 | end |
97 | 75 | end |
|
0 commit comments