Skip to content

Commit ea003cb

Browse files
Copilotdamacus
andcommitted
Fix RSpec failure by using proper test recipe instead of converge_dsl
Co-authored-by: damacus <[email protected]>
1 parent 33f55b6 commit ea003cb

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

spec/service_spec.rb

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,23 @@
3434

3535
# Test default behavior (no restart)
3636
context 'with default configuration' do
37-
let(:chef_run) do
38-
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '20.04', step_into: ['elasticsearch_service']) do |node, server|
39-
node_resources(node)
40-
stub_chef_zero('ubuntu', '20.04', server)
41-
end.converge_dsl('test') do
42-
elasticsearch_user 'elasticsearch'
43-
elasticsearch_install 'elasticsearch' do
44-
type 'package'
37+
supported_platforms.each do |platform, versions|
38+
versions.each do |version|
39+
context "on #{platform.capitalize} #{version}" do
40+
let(:chef_run) do
41+
ChefSpec::ServerRunner.new(platform: platform, version: version, step_into: ['elasticsearch_service']) do |node, server|
42+
node_resources(node)
43+
stub_chef_zero(platform, version, server)
44+
end.converge('test::default_service')
45+
end
46+
47+
it 'creates systemd unit without restart policy' do
48+
systemd_unit = chef_run.systemd_unit('elasticsearch')
49+
expect(systemd_unit.content[:Service]).not_to have_key(:Restart)
50+
expect(systemd_unit.content[:Service]).not_to have_key(:RestartSec)
51+
end
4552
end
46-
elasticsearch_configure 'elasticsearch'
47-
elasticsearch_service 'elasticsearch'
4853
end
4954
end
50-
51-
it 'creates systemd unit without restart policy' do
52-
systemd_unit = chef_run.systemd_unit('elasticsearch')
53-
expect(systemd_unit.content[:Service]).not_to have_key(:Restart)
54-
expect(systemd_unit.content[:Service]).not_to have_key(:RestartSec)
55-
end
5655
end
5756
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# test fixture to validate default service configuration (no restart policy)
2+
3+
# Basic installation and user setup
4+
elasticsearch_user 'elasticsearch'
5+
6+
elasticsearch_install 'elasticsearch' do
7+
type 'package'
8+
end
9+
10+
elasticsearch_configure 'elasticsearch' do
11+
allocated_memory '256m'
12+
action :manage
13+
end
14+
15+
# Test service with default configuration (no restart policy)
16+
elasticsearch_service 'elasticsearch' do
17+
service_actions [:enable, :start]
18+
end

0 commit comments

Comments
 (0)