Skip to content

Commit

Permalink
(CAT-1832) Globalize Puppet versions within Package tests
Browse files Browse the repository at this point in the history
  • Loading branch information
david22swan committed Jun 6, 2024
1 parent ce96924 commit b8c277f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
9 changes: 3 additions & 6 deletions package-testing/spec/package/airgapped_usage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
end

context 'when validating the module' do
context 'with puppet 8.x' do
puppet_version = '8.x'
let(:ruby_version) { ruby_for_puppet(puppet_version) }

describe command("pdk validate --puppet-version=#{puppet_version}") do
context "with puppet #{PDK_VERSION[:latest][:major]}" do
describe command("pdk validate --puppet-version=#{PDK_VERSION[:latest][:major]}") do
let(:cwd) { module_name }

its(:exit_status) { is_expected.to eq(0) }
Expand All @@ -45,7 +42,7 @@
subject { super().content.gsub(/^DEPENDENCIES.+?\n\n/m, '') }

it 'is identical to the vendored lockfile' do
vendored_lockfile = File.join(install_dir, 'share', 'cache', "Gemfile-#{ruby_version}.lock")
vendored_lockfile = File.join(install_dir, 'share', 'cache', "Gemfile-#{PDK_VERSION[:latest][:ruby]}.lock")

expect(subject).to eq(file(vendored_lockfile).content.gsub(/^DEPENDENCIES.+?\n\n/m, ''))
end
Expand Down
9 changes: 3 additions & 6 deletions package-testing/spec/package/validate_a_new_module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
end

context 'when validating the module' do
context 'with puppet 8.x' do
puppet_version = '8.x'
let(:ruby_version) { ruby_for_puppet(puppet_version) }

describe command("pdk validate --puppet-version=#{puppet_version}") do
context "with puppet #{PDK_VERSION[:latest][:major]}" do
describe command("pdk validate --puppet-version=#{PDK_VERSION[:latest][:major]}") do
let(:cwd) { module_name }

its(:exit_status) { is_expected.to eq(0) }
Expand All @@ -35,7 +32,7 @@
subject { super().content.gsub(/^DEPENDENCIES.+?\n\n/m, '') }

it 'is identical to the vendored lockfile' do
vendored_lockfile = File.join(install_dir, 'share', 'cache', "Gemfile-#{ruby_version}.lock")
vendored_lockfile = File.join(install_dir, 'share', 'cache', "Gemfile-#{PDK_VERSION[:latest][:ruby]}.lock")

expect(subject).to eq(file(vendored_lockfile).content.gsub(/^DEPENDENCIES.+?\n\n/m, ''))
end
Expand Down
9 changes: 3 additions & 6 deletions package-testing/spec/package/version_selection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

describe 'Test puppet & ruby version selection' do
module_name = 'version_selection'
# IMPORTANT: The following block should be updated with the version of ruby that is included within the newest
# Puppet release for each major version. If you are running integration testing prior to a release and its
# failing, verify that the following versions are correct.
test_cases = [
{ envvar: 'PDK_PUPPET_VERSION', expected_puppet: '7', expected_ruby: '2.7.8' },
{ envvar: 'PDK_PUPPET_VERSION', expected_puppet: '8', expected_ruby: '3.2.2' }
{ envvar: 'PDK_PUPPET_VERSION', expected_puppet: PDK_VERSION[:lts][:major], expected_ruby: PDK_VERSION[:lts][:ruby] },
{ envvar: 'PDK_PUPPET_VERSION', expected_puppet: PDK_VERSION[:latest][:major], expected_ruby: PDK_VERSION[:latest][:ruby] }
]

before(:all) do
command("pdk new module #{module_name} --skip-interview").run
command('pdk new module version_selection --skip-interview').run
end

test_cases.each do |test_case|
Expand Down
17 changes: 17 additions & 0 deletions package-testing/spec/spec_helper_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
bin_path = SpecUtils.windows_node? ? 'bin$PATH' : 'bin:$PATH'
set :path, "#{SpecUtils.install_dir}/#{bin_path}"

# IMPORTANT: The following block should be updated with the version of ruby that is included within the newest
# Puppet release for each major version. If you are running integration testing prior to a release and its
# failing, verify that the following versions are correct.
# Duplicates of this are found within spec_helper.rb and spec_helper_acceptance.rb and should be updated simultaneously.
PDK_VERSION = {
latest: {
full: '8.6.0',
major: '8',
ruby: '3.2.3'
},
lts: {
full: '7.30.0',
major: '7',
ruby: '2.7.8'
}
}.freeze

RSpec.configure do |c|
c.include SpecUtils
c.extend SpecUtils
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
end

# Sets default puppet/ruby versions to be used within the tests
# Duplicates of this are found within spec_helper_package.rb and spec_helper_acceptance.rb and should be updated simultaneously.
PDK_VERSION = {
latest: {
full: '8.6.0',
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require 'json'

# Sets default puppet/ruby versions to be used within the tests
# Duplicates of this are found within spec_helper.rb and spec_helper_package.rb and should be updated simultaneously.
PDK_VERSION = {
latest: {
full: '8.6.0',
Expand Down

0 comments on commit b8c277f

Please sign in to comment.