mirror of
https://github.com/inspec/inspec
synced 2025-02-16 22:18:38 +00:00
add test coverage for apt
This commit is contained in:
parent
abb10db376
commit
9774ec7984
3 changed files with 55 additions and 0 deletions
|
@ -173,6 +173,8 @@ class MockLoader
|
|||
# host for Linux
|
||||
'getent hosts example.com' => cmd.call('getent-hosts-example.com'),
|
||||
'ping -w 1 -c 1 example.com' => cmd.call('ping-example.com'),
|
||||
# apt
|
||||
"find /etc/apt/ -name *.list -exec sh -c 'cat {} || echo -n' \\;" => cmd.call('etc-apt'),
|
||||
}
|
||||
|
||||
# set os emulation
|
||||
|
|
7
test/unit/mock/cmd/etc-apt
Normal file
7
test/unit/mock/cmd/etc-apt
Normal file
|
@ -0,0 +1,7 @@
|
|||
deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu wily main
|
||||
# deb-src http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu wily main
|
||||
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
|
||||
# newer versions of the distribution.
|
||||
|
||||
deb http://archive.ubuntu.com/ubuntu/ wily main restricted
|
||||
deb-src http://archive.ubuntu.com/ubuntu/ wily main restricted
|
46
test/unit/resource_apt_test.rb
Normal file
46
test/unit/resource_apt_test.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
# encoding: utf-8
|
||||
# author: Christoph Hartmann
|
||||
# author: Dominik Richter
|
||||
|
||||
require 'helper'
|
||||
require 'vulcano/resource'
|
||||
|
||||
describe 'Vulcano::Resources::AptRepo' do
|
||||
|
||||
it 'check apt on ubuntu' do
|
||||
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/')
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
|
||||
it 'check apt on ubuntu with ppa' do
|
||||
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'ubuntu-wine/ppa')
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
|
||||
it 'check apt on ubuntu with ppa' do
|
||||
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'ppa:ubuntu-wine/ppa')
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
|
||||
it 'check apt on debian' do
|
||||
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/')
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
|
||||
it 'check apt on unknown os' do
|
||||
resource = MockLoader.new(:undefined).load_resource('apt', 'ubuntu-wine/ppa')
|
||||
_(resource.exists?).must_equal false
|
||||
_(resource.enabled?).must_equal false
|
||||
end
|
||||
|
||||
# check ppa resource
|
||||
it 'check apt on ubuntu' do
|
||||
resource = MockLoader.new(:ubuntu1504).load_resource('ppa', 'ubuntu-wine/ppa')
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.enabled?).must_equal true
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue