|
10 | 10 | pkg_cmd = 'dpkg -s nodejs | grep "^Maintainer"' |
11 | 11 | end |
12 | 12 |
|
| 13 | + nodejs_version = ENV.fetch('BEAKER_FACTER_nodejs_version', '20') |
| 14 | + |
13 | 15 | context 'default parameters' do |
14 | 16 | it_behaves_like 'an idempotent resource' do |
15 | 17 | let(:manifest) { "class { 'nodejs': }" } |
|
27 | 29 | end |
28 | 30 | end |
29 | 31 |
|
| 32 | + context "explicitly using version #{nodejs_version} from nodesource", if: %w[RedHat Debian].include?(fact('os.family')), skip: (nodejs_version != '16' && fact('os.family') == 'RedHat' && fact('os.release.major') == '7' ? 'Only NodeJS 16 is supported on EL7' : nil) do |
| 33 | + # Only nodejs 16 is supported on EL7 by nodesource |
| 34 | + |
| 35 | + include_examples 'cleanup' |
| 36 | + |
| 37 | + # Debian 12 contains NodeJS 18, when we test 16, we need to force the nodesource version |
| 38 | + repo_pin = |
| 39 | + if nodejs_version == '16' && fact('os.family') == 'Debian' && fact('os.release.major') == '12' |
| 40 | + '1000' |
| 41 | + else |
| 42 | + 'undef' |
| 43 | + end |
| 44 | + |
| 45 | + it_behaves_like 'an idempotent resource' do |
| 46 | + let(:manifest) do |
| 47 | + <<-PUPPET |
| 48 | + class { 'nodejs': |
| 49 | + repo_version => '#{nodejs_version}', |
| 50 | + repo_pin => #{repo_pin}, |
| 51 | + } |
| 52 | + PUPPET |
| 53 | + end |
| 54 | + end |
| 55 | + |
| 56 | + describe package('nodejs') do |
| 57 | + it { is_expected.to be_installed } |
| 58 | + |
| 59 | + it 'comes from the expected source' do |
| 60 | + pkg_output = shell(pkg_cmd) |
| 61 | + expect(pkg_output.stdout).to match 'nodesource' |
| 62 | + end |
| 63 | + end |
| 64 | + |
| 65 | + describe command('node --version') do |
| 66 | + its(:exit_status) { is_expected.to eq 0 } |
| 67 | + its(:stdout) { is_expected.to match(%r{^v#{nodejs_version}}) } |
| 68 | + end |
| 69 | + end |
| 70 | + |
30 | 71 | context 'RedHat with repo_class => epel', if: fact('os.family') == 'RedHat' do |
31 | 72 | include_examples 'cleanup' |
32 | 73 |
|
@@ -65,12 +106,11 @@ class { 'nodejs': |
65 | 106 | end |
66 | 107 | end |
67 | 108 |
|
68 | | - context 'RedHat with repo_class => nodejs::repo::dnfmodule', if: fact('os.family') == 'RedHat' && %w[8 9].include?(fact('os.release.major')) do |
69 | | - include_examples 'cleanup' |
70 | | - |
| 109 | + context 'RedHat with repo_class => nodejs::repo::dnfmodule', if: fact('os.family') == 'RedHat' && %w[8 9].include?(fact('os.release.major')), skip: ((nodejs_version == '20' && fact('os.name') != 'CentOS') || (nodejs_version == '16' && fact('os.release.major') == '9') ? 'NodeJS 20 is not yet in a released EL, NodeJS 16 is not available on EL9' : nil) do |
71 | 110 | # Node 20 is only available in Stream yet, not in a released EL |
72 | | - # So we're testing 18 here |
73 | | - nodejs_version = '18' |
| 111 | + # Node 16 is not available on EL9 |
| 112 | + |
| 113 | + include_examples 'cleanup' |
74 | 114 |
|
75 | 115 | it_behaves_like 'an idempotent resource' do |
76 | 116 | let(:manifest) do |
|
0 commit comments