Skip to content

Commit 64d87d2

Browse files
authored
Merge pull request #1207 from kenyon/fix_os_version_gte_fix
os_version_gte: fix version comparison logic
2 parents cc1fdcf + 144e24d commit 64d87d2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/puppet/functions/os_version_gte.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
def os_version_gte(os, version)
2323
facts = closure_scope['facts']
2424
(facts['operatingsystem'] == os &&
25-
Puppet::Util::Package.versioncmp(version, facts['operatingsystemmajrelease']) >= 0)
25+
Puppet::Util::Package.versioncmp(facts['operatingsystemmajrelease'], version) >= 0)
2626
end
2727
end

spec/functions/os_version_gte_spec.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
}
1212
end
1313

14+
it { is_expected.to run.with_params('Debian', '10').and_return(false) }
1415
it { is_expected.to run.with_params('Debian', '9').and_return(true) }
15-
it { is_expected.to run.with_params('Debian', '8').and_return(false) }
16-
it { is_expected.to run.with_params('Debian', '8.0').and_return(false) }
16+
it { is_expected.to run.with_params('Debian', '8').and_return(true) }
17+
it { is_expected.to run.with_params('Debian', '8.0').and_return(true) }
1718
it { is_expected.to run.with_params('Ubuntu', '16.04').and_return(false) }
1819
it { is_expected.to run.with_params('Fedora', '29').and_return(false) }
1920
end
@@ -27,9 +28,11 @@
2728
end
2829

2930
it { is_expected.to run.with_params('Debian', '9').and_return(false) }
30-
it { is_expected.to run.with_params('Ubuntu', '16').and_return(false) }
31+
it { is_expected.to run.with_params('Ubuntu', '16').and_return(true) }
32+
it { is_expected.to run.with_params('Ubuntu', '14.04').and_return(true) }
3133
it { is_expected.to run.with_params('Ubuntu', '16.04').and_return(true) }
32-
it { is_expected.to run.with_params('Ubuntu', '18.04').and_return(true) }
34+
it { is_expected.to run.with_params('Ubuntu', '18.04').and_return(false) }
35+
it { is_expected.to run.with_params('Ubuntu', '20.04').and_return(false) }
3336
it { is_expected.to run.with_params('Fedora', '29').and_return(false) }
3437
end
3538

0 commit comments

Comments
 (0)