Skip to content

Commit 88b651e

Browse files
authored
Merge pull request #142 from nwops/version
Adds testing for validate_version
2 parents 96a9408 + ae938c1 commit 88b651e

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

functions/validate_version.pp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# @return [Boolean] true if the version is supported, raise error otherwise
2+
# @param [String] the version number to check
13
function peadm::validate_version(
24
String $version,
3-
) {
5+
) >> Boolean {
46
$supported = ($version =~ SemVerRange('>= 2019.7.0 <= 2019.9.0'))
57

68
unless $supported {
@@ -15,4 +17,5 @@ function peadm::validate_version(
1517

1618
| REASON
1719
}
20+
$supported
1821
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
require 'spec_helper'
3+
4+
describe 'peadm::validate_version' do
5+
it '2020.3.0' do
6+
is_expected.to run.with_params('2020.3.0').and_raise_error(Puppet::ParseError, /This\ version\ of\ the/)
7+
end
8+
9+
it '2019.9.0' do
10+
is_expected.to run.with_params('2019.9.0').and_return(true)
11+
end
12+
13+
it '2019.8.4' do
14+
is_expected.to run.with_params('2019.8.4').and_return(true)
15+
end
16+
17+
it '2019.8.0' do
18+
is_expected.to run.with_params('2019.8.0').and_return(true)
19+
end
20+
21+
it '2019.7.1' do
22+
is_expected.to run.with_params('2019.7.1').and_return(true)
23+
end
24+
25+
it '2018.1' do
26+
is_expected.to run.with_params('2018.1').and_raise_error(Puppet::ParseError, /This\ version\ of\ the/)
27+
end
28+
end

0 commit comments

Comments
 (0)