From 15df7a68659fe9c734e6f3fc36ddfe37df7de6b1 Mon Sep 17 00:00:00 2001 From: Patrick Brideau Date: Thu, 13 Oct 2022 11:48:33 -0400 Subject: [PATCH] test: different python version on rhel8 --- metadata.json | 1 + spec/classes/apache/vhost_spec.rb | 40 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/metadata.json b/metadata.json index 73187dcd..20e0cc38 100644 --- a/metadata.json +++ b/metadata.json @@ -48,6 +48,7 @@ { "operatingsystem": "Rocky", "operatingsystemrelease": [ + "8", "9" ] }, diff --git a/spec/classes/apache/vhost_spec.rb b/spec/classes/apache/vhost_spec.rb index f3d9f215..27f95e94 100644 --- a/spec/classes/apache/vhost_spec.rb +++ b/spec/classes/apache/vhost_spec.rb @@ -46,6 +46,46 @@ 'ensure' => 'file' ) end + + if ['RedHat'].include?(facts[:os]['family']) && facts[:os]['release']['major'] == '8' + ['3.6', '3.8', '3.9'].each do |python_version| + context "with python_versions #{python_version}" do + let(:pre_condition) do + [ + "class { 'puppetboard': + python_version => \"#{python_version}\", + secret_key => 'this_should_be_a_long_secret_string', + }" + ] + end + + case python_version + when '3.6' + package_name = 'python3-mod_wsgi' + when '3.8' + package_name = 'python38-mod_wsgi' + when '3.9' + package_name = 'python39-mod_wsgi' + end + + it { is_expected.to contain_class('apache::mod::wsgi').with(package_name: package_name) } + end + end + + context 'with unsupported python_versions' do + let(:pre_condition) do + [ + "class { 'puppetboard': + python_version => '3.7', + secret_key => 'this_should_be_a_long_secret_string', + } + " + ] + end + + it { is_expected.to raise_error(Puppet::Error, %r{python version not supported}) } + end + end end end end