From f9ebda71ec0eda724097697450641345d0f0cd0d Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Thu, 13 Feb 2020 13:15:56 +0100 Subject: [PATCH] Assert distribution support This takes the approach that if a distribution is supported, it should support certain versions that Foreman supports. --- spec/puppet_version_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/puppet_version_spec.rb b/spec/puppet_version_spec.rb index 3aae7b7b6..6d200338a 100644 --- a/spec/puppet_version_spec.rb +++ b/spec/puppet_version_spec.rb @@ -3,6 +3,12 @@ describe 'Puppet module' do VERSIONS = ['5.5.10', '6.0.0'].map { |v| SemanticPuppet::Version.parse(v) } + DISTROS = { + 'CentOS' => ['7', '8'], + '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 @@ -14,12 +20,35 @@ 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 + + unless distro_versions.key?('operatingsystemrelease') + skip "No specific distribution versions listed" + end + + expect(distro_versions['operatingsystemrelease']).to include(version) + end + end + end end end end