Skip to content

Commit ba31b72

Browse files
committed
test puppet-alternatives
1 parent 9c1b209 commit ba31b72

File tree

5 files changed

+54
-19
lines changed

5 files changed

+54
-19
lines changed

.fixtures.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
fixtures:
33
repositories:
44
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib
5+
alternatives: https://github.com/voxpupuli/puppet-alternatives

REFERENCE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Classes
88

99
* [`example`](#example): An example class
10+
* [`example::profile_java`](#example--profile_java)
1011

1112
## Classes
1213

@@ -37,3 +38,19 @@ The content in the file
3738

3839
Default value: `'Hello World!'`
3940

41+
### <a name="example--profile_java"></a>`example::profile_java`
42+
43+
The example::profile_java class.
44+
45+
#### Parameters
46+
47+
The following parameters are available in the `example::profile_java` class:
48+
49+
* [`version`](#-example--profile_java--version)
50+
51+
##### <a name="-example--profile_java--version"></a>`version`
52+
53+
Data type: `Enum['8', '11', '17', '21']`
54+
55+
56+

manifests/java_profile.pp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class example::profile_java (
2+
Enum['8', '11', '17', '21'] $version,
3+
) {
4+
$_version = $version ? {
5+
'8' => '1.8.0',
6+
default => $version,
7+
}
8+
package { 'java':
9+
ensure => present,
10+
name => "java-${_version}-openjdk",
11+
}
12+
13+
alternatives { 'java':
14+
path => "java-${_version}-openjdk.${facts['os']['architecture']}",
15+
require => Package['java'],
16+
}
17+
}

metadata.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,12 @@
2525
"9"
2626
]
2727
},
28-
{
29-
"operatingsystem": "Archlinux"
30-
},
3128
{
3229
"operatingsystem": "CentOS",
3330
"operatingsystemrelease": [
3431
"9"
3532
]
3633
},
37-
{
38-
"operatingsystem": "Debian",
39-
"operatingsystemrelease": [
40-
"11",
41-
"12",
42-
"13"
43-
]
44-
},
4534
{
4635
"operatingsystem": "Fedora",
4736
"operatingsystemrelease": [
@@ -68,14 +57,6 @@
6857
"8",
6958
"9"
7059
]
71-
},
72-
{
73-
"operatingsystem": "Ubuntu",
74-
"operatingsystemrelease": [
75-
"20.04",
76-
"22.04",
77-
"24.04"
78-
]
7960
}
8061
]
8162
}

spec/classes/profile_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'profile_java' do
6+
on_supported_os.each do |os, os_facts|
7+
context "on #{os}" do
8+
let(:facts) { os_facts }
9+
let(:params) do
10+
{ 'version' => '11' }
11+
end
12+
13+
it { is_expected.to compile.with_all_deps }
14+
it { is_expected.to contain_package('java').with(name: 'java-11-openjdk-headless', ensure: 'present') }
15+
it { is_expected.to contain_alternatives('java').with(path: 'java-11-openjdk.x86_64') }
16+
it { is_expected.to contain_alternatives('java').that_requires('Package[java]') }
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)