Skip to content

Commit

Permalink
Add an additional layer of context to manage_dropin test
Browse files Browse the repository at this point in the history
This makes it easier to test with multiple unit types. It's mostly a
whitespace-only change and separating makes it easier to review.
  • Loading branch information
ekohl committed Mar 16, 2023
1 parent b008789 commit 8f77733
Showing 1 changed file with 44 additions and 37 deletions.
81 changes: 44 additions & 37 deletions spec/defines/manage_dropin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,56 @@

let(:title) { 'foobar.conf' }

context 'drop file chaning Type and resetting ExecStart' do
context 'on a service' do
let(:params) do
{
unit: 'special.service',
service_entry: {
Type: 'oneshot',
ExecStart: ['', '/usr/bin/doit.sh'],
},
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_systemd__dropin_file('foobar.conf') }

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
with_content(%r{^\[Service\]$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
without_content(%r{^\[Unit\]$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
without_content(%r{^\[Install\]$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
with_content(%r{^ExecStart=$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
with_content(%r{^ExecStart=/usr/bin/doit.sh$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
with_content(%r{^Type=oneshot$})
}
context 'drop file chaning Type and resetting ExecStart' do
let(:params) do
super().merge(
service_entry: {
Type: 'oneshot',
ExecStart: ['', '/usr/bin/doit.sh'],
},
)
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_systemd__dropin_file('foobar.conf') }

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
with_content(%r{^\[Service\]$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
without_content(%r{^\[Unit\]$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
without_content(%r{^\[Install\]$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
with_content(%r{^ExecStart=$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
with_content(%r{^ExecStart=/usr/bin/doit.sh$})
}

it {
is_expected.to contain_systemd__dropin_file('foobar.conf').
with_content(%r{^Type=oneshot$})
}
end
end
end
end
Expand Down

0 comments on commit 8f77733

Please sign in to comment.