Skip to content

Commit 9821579

Browse files
committed
Improve tests
Test the generated content as a whole instead of part of line by part of line, add add missing parameters to improve coverage.
1 parent 06f1ef7 commit 9821579

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

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: true,
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)