test: fix existing tests

This commit is contained in:
Imran Iqbal 2019-10-03 22:35:30 +01:00
parent 1755f76fde
commit 8e75c9d5c0
No known key found for this signature in database
GPG key ID: 6D8629439D2B7819
4 changed files with 25 additions and 27 deletions

View file

@ -16,7 +16,7 @@ control 'Wanted/Required npm packages' do
desc '(only testing in the Debian platform, as the node-formula dependency is too specific)' desc '(only testing in the Debian platform, as the node-formula dependency is too specific)'
only_if do only_if do
os.name == 'debian' platform.name == 'debian'
end end
describe directory(npms_path) do describe directory(npms_path) do
@ -39,7 +39,7 @@ control 'Unwanted npm packages' do
desc '(only testing in the Debian platform, as the node-formula dependency is too specific)' desc '(only testing in the Debian platform, as the node-formula dependency is too specific)'
only_if do only_if do
os.name == 'debian' platform.name == 'debian'
end end
%w{ %w{

View file

@ -1,6 +1,6 @@
### WANTED/REQUIRED ### WANTED/REQUIRED
case os[:name] case platform[:family]
when 'fedora', 'opensuse' when 'fedora', 'suse'
wanted_pips = [] wanted_pips = []
else else
wanted_pips = %w{ wanted_pips = %w{

View file

@ -7,9 +7,9 @@ common_packages = %w(
fail2ban fail2ban
) )
case os[:name] case platform[:family]
when 'redhat', 'centos' when 'redhat'
os_packages = %w(yum-plugin-versionlock) platform_packages = %w(yum-plugin-versionlock)
held_packages = { held_packages = {
# We use this test for held packages in a list, # We use this test for held packages in a list,
# with no version (current version). # with no version (current version).
@ -18,11 +18,11 @@ when 'redhat', 'centos'
} }
lock_file = '/etc/yum/pluginconf.d/versionlock.list' lock_file = '/etc/yum/pluginconf.d/versionlock.list'
when 'fedora' when 'fedora'
case os[:release] case platform[:release]
when '29' when '29'
os_packages = ['python2-dnf-plugin-versionlock'] platform_packages = ['python2-dnf-plugin-versionlock']
when '30' when '30'
os_packages = ['python3-dnf-plugin-versionlock'] platform_packages = ['python3-dnf-plugin-versionlock']
end end
held_packages = { held_packages = {
'alien': '8.95-8.fc29', 'alien': '8.95-8.fc29',
@ -31,12 +31,12 @@ when 'fedora'
lock_file = '/etc/dnf/plugins/versionlock.list' lock_file = '/etc/dnf/plugins/versionlock.list'
# Adding empty Suse entries, to get tests passing # Adding empty Suse entries, to get tests passing
# Don't know the correct values to add here. # Don't know the correct values to add here.
when 'opensuse' when 'suse'
os_packages = %w() platform_packages = %w()
held_packages = {} held_packages = {}
lock_file = '' lock_file = ''
when 'debian', 'ubuntu' when 'debian'
os_packages = %w() platform_packages = %w()
held_packages = { held_packages = {
'alien': '8.95', 'alien': '8.95',
# To match also ubuntu16's # To match also ubuntu16's
@ -45,14 +45,14 @@ when 'debian', 'ubuntu'
lock_file = '/var/lib/dpkg/status' lock_file = '/var/lib/dpkg/status'
when 'amazon' when 'amazon'
common_packages.delete('fail2ban') common_packages.delete('fail2ban')
os_packages = ['git'] platform_packages = ['git']
held_packages = [] held_packages = []
end end
## FIXME - not testing Held packages ## FIXME - not testing Held packages
held_packages = {} held_packages = {}
unheld_packages = (common_packages + os_packages).flatten.uniq unheld_packages = (common_packages + platform_packages).flatten.uniq
all_packages = (unheld_packages + held_packages.keys.map { |k| k.to_s }).flatten.uniq all_packages = (unheld_packages + held_packages.keys.map { |k| k.to_s }).flatten.uniq
### WANTED/REQUIRED/HELD ### WANTED/REQUIRED/HELD
@ -71,13 +71,13 @@ control 'Wanted packages' do
title 'should NOT be marked as hold' title 'should NOT be marked as hold'
unheld_packages.each do |p,v| unheld_packages.each do |p,v|
case os[:name] case platform[:family]
when 'redhat', 'centheld_packagesheld_packagesos', 'fedora' when 'redhat', 'fedora'
match_string = "#{p}-.*#{v}" match_string = "#{p}-.*#{v}"
describe file(lock_file) do describe file(lock_file) do
its('content') { should_not match(match_string) } its('content') { should_not match(match_string) }
end end
when 'debian', 'ubuntu' when 'debian'
match_string = "^Package: #{p}\nStatus: install ok installed" match_string = "^Package: #{p}\nStatus: install ok installed"
describe file(lock_file) do describe file(lock_file) do
its('content') { should match(match_string) } its('content') { should match(match_string) }
@ -91,10 +91,10 @@ control 'Held packages' do
title 'should be marked as hold' title 'should be marked as hold'
held_packages.each do |p,v| held_packages.each do |p,v|
case os[:name] case platform[:family]
when 'redhat', 'centos', 'fedora' when 'redhat', 'fedora'
match_string = "#{p}-.*#{v}" match_string = "#{p}-.*#{v}"
when 'debian', 'ubuntu' when 'debian'
match_string = "^Package: #{p}\nStatus: hold ok installed\nP.*\nS.*\nI.*\nM.*\nA.*\nVersion: #{v}" match_string = "^Package: #{p}\nStatus: hold ok installed\nP.*\nS.*\nI.*\nM.*\nA.*\nVersion: #{v}"
end end

View file

@ -1,17 +1,15 @@
### REMOTE PKGS ### REMOTE PKGS
remote_pkgs = ['zoom'] remote_pkgs = ['zoom']
case os[:name] case platform[:family]
when 'opensuse' when 'suse'
remote_pkgs = [] remote_pkgs = []
end end
control 'Remote packages' do control 'Remote packages' do
title 'should be downloaded and installed' title 'should be downloaded and installed'
%w{ remote_pkgs.each do |p|
zoom
}.each do |p|
describe package(p) do describe package(p) do
it { should be_installed } it { should be_installed }
end end