File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # @summary Manage the DNF module
2+ #
3+ # On EL8+ DNF can manage modules.
4+ # This is a method of providing multiple versions on the same OS.
5+ # Only one DNF module stream can be active at the same time.
6+ #
7+ # @param ensure
8+ # Value of ensure parameter for nodejs dnf module package
9+ #
10+ # @param module
11+ # Name of the nodejs dnf package
12+ #
13+ # @api private
14+ class nodejs::repo::dnfmodule (
15+ String[1] $ensure = $nodejs::repo_version,
16+ String[1] $module = ' nodejs' ,
17+ ) {
18+ package { 'nodejs dnf module' :
19+ ensure => $ensure ,
20+ name => $module ,
21+ enable_only => true ,
22+ provider => ' dnfmodule' ,
23+ }
24+ }
Original file line number Diff line number Diff line change @@ -65,6 +65,49 @@ class { 'nodejs':
6565 end
6666 end
6767
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+
71+ # Node 20 is only available in Stream yet, not in a released EL
72+ # So we're testing 18 here
73+ nodejs_version = '18'
74+
75+ it_behaves_like 'an idempotent resource' do
76+ let ( :manifest ) do
77+ <<-PUPPET
78+ class { 'nodejs':
79+ nodejs_dev_package_ensure => installed,
80+ npm_package_ensure => installed,
81+ repo_class => 'nodejs::repo::dnfmodule',
82+ repo_version => '#{ nodejs_version } ',
83+ }
84+ PUPPET
85+ end
86+ end
87+
88+ %w[
89+ npm
90+ nodejs
91+ nodejs-devel
92+ ] . each do |pkg |
93+ describe package ( pkg ) do
94+ it do
95+ is_expected . to be_installed
96+ end
97+
98+ it 'comes from the expected source' do
99+ pkg_output = shell ( pkg_cmd )
100+ expect ( pkg_output . stdout ) . to match 'appstream'
101+ end
102+ end
103+ end
104+
105+ describe command ( 'node --version' ) do
106+ its ( :exit_status ) { is_expected . to eq 0 }
107+ its ( :stdout ) { is_expected . to match ( %r{^v#{ nodejs_version } } ) }
108+ end
109+ end
110+
68111 context 'Debian distribution packages' , if : fact ( 'os.family' ) == 'Debian' do
69112 before ( :context ) { purge_node }
70113
You can’t perform that action at this time.
0 commit comments