Skip to content

Commit

Permalink
test different NodeJS versions using beaker_facter
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Oct 30, 2023
1 parent a10de4a commit ecef55b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ jobs:
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
with:
pidfile_workaround: 'false'
beaker_facter: 'nodejs_version:NodeJS:16,18,20'
2 changes: 2 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ spec/spec_helper.rb:
mock_with: ':mocha'
spec/spec_helper_acceptance.rb:
unmanaged: true
.github/workflows/ci.yml:
beaker_facter: 'nodejs_version:NodeJS:16,18,20'
38 changes: 34 additions & 4 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
pkg_cmd = 'dpkg -s nodejs | grep "^Maintainer"'
end

nodejs_version = fact('nodejs_version') || '20'

context 'default parameters' do
it_behaves_like 'an idempotent resource' do
let(:manifest) { "class { 'nodejs': }" }
Expand All @@ -27,6 +29,34 @@
end
end

context "explicitly using version #{nodejs_version} from nodesource", if: %w[RedHat Debian].include? fact('os.family') do

Check failure on line 32 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Lint/Syntax: unexpected token tIDENTIFIER (Using Ruby 2.6 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)
include_examples 'cleanup'

it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'nodejs':
repo_version => '#{nodejs_version}'
}
PUPPET
end
end

describe package('nodejs') do
it { is_expected.to be_installed }

it 'comes from the expected source' do
pkg_output = shell(pkg_cmd)
expect(pkg_output.stdout).to match 'nodesource'
end
end

describe command('node --version') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match(%r{^v#{nodejs_version}}) }
end
end

context 'RedHat with repo_class => epel', if: fact('os.family') == 'RedHat' do
include_examples 'cleanup'

Expand Down Expand Up @@ -66,11 +96,11 @@ class { 'nodejs':
end

context 'RedHat with repo_class => nodejs::repo::dnfmodule', if: fact('os.family') == 'RedHat' && %w[8 9].include?(fact('os.release.major')) do
include_examples 'cleanup'

# Node 20 is only available in Stream yet, not in a released EL
# So we're testing 18 here
nodejs_version = '18'
# So we're not testing it here yet
skip if nodejs_version == '20' && fact('os.name') != 'CentOS'

include_examples 'cleanup'

it_behaves_like 'an idempotent resource' do
let(:manifest) do
Expand Down

0 comments on commit ecef55b

Please sign in to comment.