summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorFelix Bechstein <felix.bechstein@otto.de>2016-01-27 08:18:12 +0100
committerFelix Bechstein <felix.bechstein@otto.de>2016-01-27 11:41:56 +0100
commit040f1acf02dc379e3fe577d900b96b47a38a714a (patch)
tree5856d634a5a78b82bd5b89799b8aa621d5e8fa5e /spec
parent6d47fd4999fe03eba6fb11c4490dcbb90d937900 (diff)
Shortcut for creating unit files / tmpfiles
This change allows creating unit files and reloading systemd with just a single resource. It's fully compatible with the manual behavior.
Diffstat (limited to 'spec')
-rw-r--r--spec/defines/tmpfile_spec.rb48
-rw-r--r--spec/defines/unit_file_spec.rb48
2 files changed, 96 insertions, 0 deletions
diff --git a/spec/defines/tmpfile_spec.rb b/spec/defines/tmpfile_spec.rb
new file mode 100644
index 0000000..4eb22ac
--- /dev/null
+++ b/spec/defines/tmpfile_spec.rb
@@ -0,0 +1,48 @@
+require 'spec_helper'
+
+describe 'systemd::tmpfile' do
+
+ let(:facts) { {
+ :path => '/usr/bin',
+ } }
+
+ context 'default params' do
+
+ let(:title) { 'fancy.conf' }
+
+ it 'creates the tmpfile' do
+ should contain_file('/etc/tmpfiles.d/fancy.conf').with({
+ 'ensure' => 'file',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0444',
+ })
+ end
+
+ it 'triggers systemd daemon-reload' do
+ should contain_class('systemd')
+ should contain_file('/etc/tmpfiles.d/fancy.conf').with_notify("Exec[systemd-tmpfiles-create]")
+ end
+ end
+
+ context 'with params' do
+ let(:title) { 'fancy.conf' }
+
+ let(:params) { {
+ :ensure => 'absent',
+ :path => '/etc/tmpfiles.d/foo',
+ :content => 'some-content',
+ :source => 'some-source',
+ } }
+
+ it 'creates the unit file' do
+ should contain_file('/etc/tmpfiles.d/foo/fancy.conf').with({
+ 'ensure' => 'absent',
+ 'content' => 'some-content',
+ 'source' => 'some-source',
+ })
+ end
+
+ end
+
+end
diff --git a/spec/defines/unit_file_spec.rb b/spec/defines/unit_file_spec.rb
new file mode 100644
index 0000000..0eebbd3
--- /dev/null
+++ b/spec/defines/unit_file_spec.rb
@@ -0,0 +1,48 @@
+require 'spec_helper'
+
+describe 'systemd::unit_file' do
+
+ let(:facts) { {
+ :path => '/usr/bin',
+ } }
+
+ context 'default params' do
+
+ let(:title) { 'fancy.service' }
+
+ it 'creates the unit file' do
+ should contain_file('/etc/systemd/system/fancy.service').with({
+ 'ensure' => 'file',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0444',
+ })
+ end
+
+ it 'triggers systemd daemon-reload' do
+ should contain_class('systemd')
+ should contain_file('/etc/systemd/system/fancy.service').with_notify("Exec[systemctl-daemon-reload]")
+ end
+ end
+
+ context 'with params' do
+ let(:title) { 'fancy.service' }
+
+ let(:params) { {
+ :ensure => 'absent',
+ :path => '/usr/lib/systemd/system',
+ :content => 'some-content',
+ :source => 'some-source',
+ } }
+
+ it 'creates the unit file' do
+ should contain_file('/usr/lib/systemd/system/fancy.service').with({
+ 'ensure' => 'absent',
+ 'content' => 'some-content',
+ 'source' => 'some-source',
+ })
+ end
+
+ end
+
+end