Skip to content

Commit 451d76d

Browse files
committed
test(inspec): add tests for package, config & service
1 parent 62122d2 commit 451d76d

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
control 'Docker configuration' do
4+
title 'should match desired lines'
5+
6+
describe file('/etc/default/docker') do
7+
it { should be_file }
8+
its('owner') { should eq 'root' }
9+
its('group') { should eq 'root' }
10+
its('mode') { should cmp '0644' }
11+
its('content') { should include 'DOCKER_OPTS="-s btrfs --dns 8.8.8.8"' }
12+
its('content') { should include 'export http_proxy="http://172.17.42.1:3128"' }
13+
end
14+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
control 'Docker package' do
4+
title 'should be installed'
5+
6+
package_name =
7+
case platform[:family]
8+
when 'debian'
9+
'docker-ce'
10+
# Catch remaining `linux` platforms to identify by `name` at the end
11+
when 'linux'
12+
case platform[:name]
13+
when 'arch'
14+
'docker'
15+
end
16+
end
17+
18+
describe package(package_name) do
19+
it { should be_installed }
20+
end
21+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
control 'Docker service' do
4+
title 'should be running and enabled'
5+
6+
describe service('docker') do
7+
it { should be_installed }
8+
it { should be_enabled }
9+
it { should be_running }
10+
end
11+
end

0 commit comments

Comments
 (0)