Skip to content

Commit

Permalink
test(inspec): add tests for package, config & service
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Oct 16, 2019
1 parent 62122d2 commit 451d76d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/integration/default/controls/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

control 'Docker configuration' do
title 'should match desired lines'

describe file('/etc/default/docker') do
it { should be_file }
its('owner') { should eq 'root' }
its('group') { should eq 'root' }
its('mode') { should cmp '0644' }
its('content') { should include 'DOCKER_OPTS="-s btrfs --dns 8.8.8.8"' }
its('content') { should include 'export http_proxy="http://172.17.42.1:3128"' }
end
end
21 changes: 21 additions & 0 deletions test/integration/default/controls/package.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

control 'Docker package' do
title 'should be installed'

package_name =
case platform[:family]
when 'debian'
'docker-ce'
# Catch remaining `linux` platforms to identify by `name` at the end
when 'linux'
case platform[:name]
when 'arch'
'docker'
end
end

describe package(package_name) do
it { should be_installed }
end
end
11 changes: 11 additions & 0 deletions test/integration/default/controls/service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

control 'Docker service' do
title 'should be running and enabled'

describe service('docker') do
it { should be_installed }
it { should be_enabled }
it { should be_running }
end
end

0 comments on commit 451d76d

Please sign in to comment.