Skip to content

Commit d3b3594

Browse files
committed
Stop sources format and ensure => absent failing
Currently the following produces a compile error every time. ```puppet apt::source{ ensure => absent, source_format => sources, } ``` ``` Puppet::PreformattedError: Evaluation Error: Error while evaluating a Resource Statement, Apt::Setting[sources-my_source]: parameter 'content' expects a value of type Undef or String[1], got String (file: /home/steve/GIT/puppetlabs-apt/spec/fixtures/modules/apt/manifests/source.pp, line: 363) on node legion.lan ```
1 parent 677b2b3 commit d3b3594

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

manifests/source.pp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@
254254
'components' => $_components,
255255
}
256256
)
257+
$_content = "${header}${source_content}"
257258

258259
if $pin {
259260
if $pin =~ Hash {
@@ -346,10 +347,10 @@
346347
}
347348
)
348349
)
350+
$_content = "${header}${source_content}"
349351
}
350352
'absent': {
351-
$header = undef
352-
$source_content = undef
353+
$_content = undef
353354
}
354355
default: {
355356
fail('Unexpected value for $ensure parameter.')
@@ -362,7 +363,7 @@
362363
}
363364
apt::setting { "${_file_suffix}-${name}":
364365
ensure => $ensure,
365-
content => "${header}${source_content}",
366+
content => $_content,
366367
notify_update => $notify_update,
367368
}
368369
}

spec/defines/source_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,5 +516,36 @@
516516

517517
it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(true) }
518518
end
519+
520+
context 'absent deb822 source' do
521+
let :params do
522+
super().merge(
523+
{
524+
ensure: 'absent',
525+
},
526+
)
527+
end
528+
529+
it { is_expected.to contain_apt__setting("sources-#{title}").with_ensure('absent') }
530+
end
531+
532+
context 'absent complex deb822 source' do
533+
let :params do
534+
super().merge(
535+
{
536+
ensure: 'absent',
537+
types: ['deb', 'deb-src'],
538+
location: ['http://fr.debian.org/debian', 'http://de.debian.org/debian'],
539+
release: ['stable', 'stable-updates', 'stable-backports'],
540+
repos: ['main', 'contrib', 'non-free'],
541+
architecture: ['amd64', 'i386'],
542+
allow_unsigned: true,
543+
notify_update: false
544+
},
545+
)
546+
end
547+
548+
it { is_expected.to contain_apt__setting("sources-#{title}").with_ensure('absent') }
549+
end
519550
end
520551
end

0 commit comments

Comments
 (0)