diff --git a/manifests/repo.pp b/manifests/repo.pp index d717792..a0203fe 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -3,7 +3,7 @@ # @param version # The Pulpcore version to use class pulpcore::repo ( - Pattern['^\d+\.\d+$'] $version = '3.28', + Variant[Enum['nightly'], Pattern['^\d+\.\d+$']] $version = '3.28', ) { $dist_tag = "el${facts['os']['release']['major']}" $context = { diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index 77aa440..0da9730 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -5,26 +5,43 @@ context "on #{os}" do let(:facts) { os_facts } - it { is_expected.to compile.with_all_deps } - it do - is_expected.to contain_anchor('pulpcore::repo') - is_expected.to contain_file('/etc/yum.repos.d/pulpcore.repo') - .with_content(%r{^baseurl=https://yum.theforeman.org/pulpcore/\d+\.\d+/el\d+/\$basearch$}) - .that_notifies('Anchor[pulpcore::repo]') + describe "with default values" do + it { is_expected.to compile.with_all_deps } + it do + is_expected.to contain_anchor('pulpcore::repo') + is_expected.to contain_file('/etc/yum.repos.d/pulpcore.repo') + .with_content(%r{^baseurl=https://yum.theforeman.org/pulpcore/\d+\.\d+/el\d+/\$basearch$}) + .that_notifies('Anchor[pulpcore::repo]') + end + + if os_facts[:os]['release']['major'] == '8' + it 'configures the pulpcore module' do + is_expected.to contain_package('pulpcore-dnf-module') + .with_name('pulpcore') + .with_ensure(/^el\d+/) + .with_enable_only(true) + .with_provider('dnfmodule') + .that_requires('File[/etc/yum.repos.d/pulpcore.repo]') + .that_notifies('Anchor[pulpcore::repo]') + end + else + it { is_expected.not_to contain_package('pulpcore-dnf-module') } + end end - if os_facts[:os]['release']['major'] == '8' - it 'configures the pulpcore module' do - is_expected.to contain_package('pulpcore-dnf-module') - .with_name('pulpcore') - .with_ensure(/^el\d+/) - .with_enable_only(true) - .with_provider('dnfmodule') - .that_requires('File[/etc/yum.repos.d/pulpcore.repo]') + describe "with nightly version" do + let :params do + { + version: 'nightly' + } + end + + it { is_expected.to compile.with_all_deps } + it do + is_expected.to contain_file('/etc/yum.repos.d/pulpcore.repo') + .with_content(%r{^baseurl=https://yum.theforeman.org/pulpcore/nightly/el\d+/\$basearch$}) .that_notifies('Anchor[pulpcore::repo]') end - else - it { is_expected.not_to contain_package('pulpcore-dnf-module') } end end end