@@ -92,32 +92,62 @@ def param(type, title, param)
92
92
end
93
93
end
94
94
95
+ # This duplicates spec_helper but we need it for add_custom_fact
96
+ include RspecPuppetFacts
97
+ # Rough conversion of grepping in the puppet source:
98
+ # grep defaultfor lib/puppet/provider/service/*.rb
99
+ # See https://github.com/voxpupuli/voxpupuli-test/blob/master/lib/voxpupuli/test/facts.rb
100
+ add_custom_fact :service_provider , -> ( _os , facts ) do
101
+ case facts [ :osfamily ] . downcase
102
+ when 'archlinux'
103
+ 'systemd'
104
+ when 'darwin'
105
+ 'launchd'
106
+ when 'debian'
107
+ 'systemd'
108
+ when 'freebsd'
109
+ 'freebsd'
110
+ when 'gentoo'
111
+ 'openrc'
112
+ when 'openbsd'
113
+ 'openbsd'
114
+ when 'redhat'
115
+ facts [ :operatingsystemrelease ] . to_i >= 7 ? 'systemd' : 'redhat'
116
+ when 'suse'
117
+ facts [ :operatingsystemmajrelease ] . to_i >= 12 ? 'systemd' : 'redhat'
118
+ when 'windows'
119
+ 'windows'
120
+ else
121
+ 'init'
122
+ end
123
+ end
124
+
95
125
shared_context 'Debian 9' do
96
- let ( :facts ) { on_supported_os [ 'debian-9-x86_64' ] . merge ( service_provider : 'systemd' ) }
126
+ let ( :facts ) { on_supported_os [ 'debian-9-x86_64' ] }
97
127
end
98
128
99
129
shared_context 'Debian 10' do
100
- let ( :facts ) { on_supported_os [ 'debian-10-x86_64' ] . merge ( service_provider : 'systemd' ) }
130
+ let ( :facts ) { on_supported_os [ 'debian-10-x86_64' ] }
101
131
end
102
132
103
133
shared_context 'Debian 11' do
104
- let ( :facts ) { on_supported_os [ 'debian-11-x86_64' ] . merge ( service_provider : 'systemd' ) }
134
+ let ( :facts ) { on_supported_os [ 'debian-11-x86_64' ] }
105
135
end
106
136
107
137
shared_context 'Ubuntu 18.04' do
108
- let ( :facts ) { on_supported_os [ 'ubuntu-18.04-x86_64' ] . merge ( service_provider : 'systemd' ) }
138
+ let ( :facts ) { on_supported_os [ 'ubuntu-18.04-x86_64' ] }
109
139
end
110
140
111
141
shared_context 'RedHat 6' do
112
- let ( :facts ) { on_supported_os [ 'redhat-6-x86_64' ] . merge ( service_provider : 'redhat' ) }
142
+ let ( :facts ) { on_supported_os [ 'redhat-6-x86_64' ] }
113
143
end
114
144
115
145
shared_context 'RedHat 7' do
116
- let ( :facts ) { on_supported_os [ 'redhat-7-x86_64' ] . merge ( service_provider : 'systemd' ) }
146
+ let ( :facts ) { on_supported_os [ 'redhat-7-x86_64' ] }
117
147
end
118
148
119
149
shared_context 'RedHat 8' do
120
- let ( :facts ) { on_supported_os [ 'redhat-8-x86_64' ] . merge ( service_provider : 'systemd' ) }
150
+ let ( :facts ) { on_supported_os [ 'redhat-8-x86_64' ] }
121
151
end
122
152
123
153
shared_context 'Fedora 33' do
0 commit comments