Skip to content

Commit

Permalink
Add tests for static units (.service triggered by .timer)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Deziel <[email protected]>
  • Loading branch information
simondeziel committed Oct 19, 2021
1 parent e4907f1 commit b705e44
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/defines/timer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@
it { is_expected.to contain_systemd__unit_file('gamma.service').with_content("[Service]\nExecStart=/bin/touch /tmp/foobar") }
end

context 'with timer activated service' do
let(:params) do
{
active: true,
enable: true,
timer_content: "[Timer]\nOnCalendar=hourly",
service_content: "[Service]\nExecStart=/bin/echo timer-fired",
}
end

it { is_expected.to contain_systemd__unit_file('foobar.timer').with_content("[Timer]\nOnCalendar=hourly") }
it { is_expected.to contain_systemd__unit_file('foobar.service').with_content("[Service]\nExecStart=/bin/echo timer-fired") }

it {
is_expected.to create_exec('foobar.service-systemctl-daemon-reload').with(
command: 'systemctl daemon-reload',
refreshonly: true
)
}
end

context 'with a bad timer name' do
let(:title) { 'foobar' }

Expand Down
9 changes: 9 additions & 0 deletions spec/defines/unit_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@
end
end
end

context 'when using default values for enable and active' do
it {
is_expected.to create_exec("#{title}-systemctl-daemon-reload").with(
command: 'systemctl daemon-reload',
refreshonly: true
)
}
end
end
end
end
Expand Down

0 comments on commit b705e44

Please sign in to comment.