-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_spec.rb
118 lines (100 loc) · 3.54 KB
/
service_spec.rb
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
require 'spec_helper'
describe 'example' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }
context 'with install_dir set to /opt/special and manage_service set to true and service_provider set to systemd' do
let(:params) do
{
install_dir: '/opt/special',
manage_service: true,
service_name: 'example',
service_provider: 'systemd',
}
end
it { is_expected.to contain_systemd__Unit_file('example.service').with_content(%r{^ExecStart=/opt/special/example}) }
end
context 'with manage_service set to true' do
let(:params) do
{
manage_service: true,
service_name: 'example',
}
end
it { is_expected.to contain_service('example') }
end
context 'with manage_service set to false' do
let(:params) do
{
manage_service: false,
service_name: 'example',
}
end
it { is_expected.not_to contain_service('example') }
end
context 'with package_name set to specialpackage and manage_service set to true' do
let(:params) do
{
install_method: 'package',
manage_service: true,
package_name: 'specialpackage',
service_name: 'example',
}
end
it { is_expected.to contain_package('example').with_name('specialpackage') }
end
context 'with service_name set to specialservice' do
let(:params) do
{
manage_service: true,
service_name: 'specialservice',
}
end
it { is_expected.to contain_service('example').with_name('specialservice') }
end
context 'with service_name set to specialservice and with service_provider set to systemd' do
let(:params) do
{
manage_service: true,
service_name: 'specialservice',
service_provider: 'systemd',
}
end
it { is_expected.to contain_service('example').with_name('specialservice') }
it { is_expected.to contain_systemd__Unit_file('specialservice.service').that_comes_before('Service[example]').with_content(%r{^Description=specialservice}) }
end
context 'with service_name set to specialservice and with install_method set to package' do
let(:params) do
{
install_method: 'package',
manage_service: true,
package_name: 'example',
service_name: 'specialservice',
}
end
it { is_expected.to contain_service('example').with_name('specialservice').that_subscribes_to('Package[example]') }
end
context 'with service_provider set to systemd' do
let(:params) do
{
manage_service: true,
service_name: 'example',
service_provider: 'systemd',
}
end
it { is_expected.not_to contain_file('example service file').with_path('/etc/init.d/example') }
it { is_expected.to contain_systemd__Unit_file('example.service').that_comes_before('Service[example]') }
it { is_expected.to contain_service('example') }
end
context 'with service_provider set to invalid' do
let(:params) do
{
manage_service: true,
service_provider: 'invalid',
}
end
it { is_expected.to raise_error(%r{Service provider invalid not supported}) }
end
end
end
end