Skip to content

Commit

Permalink
Merge pull request #791 from eimlav/puppet4ify
Browse files Browse the repository at this point in the history
(FM-7320) - Removed assert_type statements
  • Loading branch information
Helen authored Aug 31, 2018
2 parents 0cfcade + 9b3254e commit 46296cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
29 changes: 7 additions & 22 deletions manifests/key.pp
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
# == Define: apt::key
define apt::key (
String $id = $title,
Enum['present', 'absent'] $ensure = present,
Optional[String] $content = undef,
Optional[String] $source = undef,
String $server = $::apt::keyserver,
Optional[String] $options = undef,
) {

assert_type(
Pattern[
/\A(0x)?[0-9a-fA-F]{8}\Z/,
/\A(0x)?[0-9a-fA-F]{16}\Z/,
/\A(0x)?[0-9a-fA-F]{40}\Z/,
], $id)

if $source {
assert_type(Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/], $source)
}

if $server {
assert_type(Pattern[/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/], $server)
}
Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/] $id = $title,
Enum['present', 'absent'] $ensure = present,
Optional[String] $content = undef,
Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source = undef,
Pattern[/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/] $server = $::apt::keyserver,
Optional[String] $options = undef,
) {

case $ensure {
present: {
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/key_compat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def apt_key_example(title)
end

it 'fails' do
is_expected.to raise_error(%r{expects a match})
is_expected.to raise_error(%r{evaluating a Resource})
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/defines/key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def absent_apt_key(title)
end

it 'fails' do
is_expected.to raise_error(%r{expects a match})
is_expected.to raise_error(%r{evaluating a Resource})
end
end

Expand Down

0 comments on commit 46296cb

Please sign in to comment.