Skip to content

Commit 3186d23

Browse files
committed
Improve tests
Test the generated content as a whole instead of part of line by part of line, add missing parameters, this allows to find an error that is also fixed in this commit.
1 parent cd98f10 commit 3186d23

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

manifests/source.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
'comment' => $comment,
341341
'enabled' => $enabled ? { true => 'yes', false => 'no' },
342342
'architectures' => $_architecture,
343-
'allow_insecure' => $allow_insecure ? { true => 'yes', false => 'no', default => undef },
343+
'allow_insecure' => $allow_insecure ? { false => 'yes', default => undef },
344344
'repo_trusted' => $allow_unsigned ? { true => 'yes', false => 'no', default => undef },
345345
'check_valid_until' => $check_valid_until ? { true => 'yes', false => 'no', default => undef },
346346
'signed_by' => $keyring,

spec/defines/source_spec.rb

+28-8
Original file line numberDiff line numberDiff line change
@@ -435,31 +435,51 @@
435435
end
436436

437437
it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(true) }
438+
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(<<~SOURCE) }
439+
# This file is managed by Puppet. DO NOT EDIT.
440+
# my_source
441+
Enabled: yes
442+
Types: deb
443+
URIs: http://debian.mirror.iweb.ca/debian/
444+
Suites: stretch
445+
Components: main contrib non-free
446+
SOURCE
438447
end
439448

440449
context 'complex deb822 source' do
441450
let :params do
442451
super().merge(
443452
{
453+
enabled: false,
444454
types: ['deb', 'deb-src'],
445455
location: ['http://fr.debian.org/debian', 'http://de.debian.org/debian'],
446456
release: ['stable', 'stable-updates', 'stable-backports'],
447457
repos: ['main', 'contrib', 'non-free'],
448458
architecture: ['amd64', 'i386'],
449459
allow_unsigned: true,
450-
notify_update: false
460+
allow_insecure: false,
461+
notify_update: false,
462+
check_valid_until: false,
463+
keyring: '/foo'
451464
},
452465
)
453466
end
454467

455468
it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(false) }
456-
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Enabled: yes}) }
457-
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Types: deb deb-src}) }
458-
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{URIs: http://fr.debian.org/debian http://de.debian.org/debian}) }
459-
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Suites: stable stable-updates stable-backports}) }
460-
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Components: main contrib non-free}) }
461-
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Architectures: amd64 i386}) }
462-
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Trusted: yes}) }
469+
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(<<~SOURCE) }
470+
# This file is managed by Puppet. DO NOT EDIT.
471+
# my_source
472+
Enabled: no
473+
Types: deb deb-src
474+
URIs: http://fr.debian.org/debian http://de.debian.org/debian
475+
Suites: stable stable-updates stable-backports
476+
Components: main contrib non-free
477+
Architectures: amd64 i386
478+
Allow-Insecure: yes
479+
Trusted: yes
480+
Check-Valid-Until: no
481+
Signed-By: /foo
482+
SOURCE
463483
end
464484

465485
context '.list backwards compatibility' do

0 commit comments

Comments
 (0)