Skip to content

Commit

Permalink
Assert distribution support
Browse files Browse the repository at this point in the history
This takes the approach that if a distribution is supported, it should
support certain versions that Foreman supports.
  • Loading branch information
ekohl committed Feb 14, 2020
1 parent e4b56a0 commit 4888a34
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/puppet_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

describe 'Puppet module' do
VERSIONS = ['5.5.10', '6.0.0'].map { |v| SemanticPuppet::Version.parse(v) }
DISTROS = {
'CentOS' => ['7'],
'Debian' => ['10'],
'RedHat' => ['7'],
'Ubuntu' => ['18.04'],
}

Dir.glob(File.join(__dir__, '../_build/modules/*/metadata.json')).each do |filename|
context File.basename(File.dirname(filename)) do
Expand All @@ -14,12 +20,32 @@
version_requirement ||= '>= 0'
SemanticPuppet::VersionRange.parse(version_requirement)
end
let(:operatingsystem_support) { metadata['operatingsystem_support'] }

VERSIONS.each do |puppet_version|
it "should support Puppet #{puppet_version}" do
expect(puppet_requirement).to include(puppet_version)
end
end

DISTROS.each do |distro, versions|
versions.each do |version|
it "should support #{distro} #{version}" do
if operatingsystem_support.nil?
skip "No OS support listed"
end

distro_versions = operatingsystem_support.find { |os| os['operatingsystem'] == distro }

if distro_versions.nil?
skip "Distribution #{distro} is not supported"
end

expect(distro_versions).to have_key('operatingsystemrelease')
expect(distro_versions['operatingsystemrelease']).to include(version)
end
end
end
end
end
end

0 comments on commit 4888a34

Please sign in to comment.