Skip to content

Commit 5373dea

Browse files
committed
Add additional unit-test; configure inheritance of param
1 parent b3d5f7c commit 5373dea

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

spec/classes/init_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
'docker_msft_provider_version' => '123',
3131
'nuget_package_provider_version' => '41',
3232
},
33+
'with keyring set to optional path' => {
34+
'keyring' => '/root/keyrings/docker.gpg',
35+
},
3336
}
3437

3538
describe 'docker', type: :class do
@@ -180,6 +183,7 @@
180183
'tmp_dir' => defaults['tmp_dir'],
181184
'use_upstream_package_source' => defaults['use_upstream_package_source'],
182185
'version' => defaults['version'],
186+
'keyring' => defaults['keyring']
183187
}.merge(default_params).merge(local_params)
184188

185189
let(:facts) do

spec/helper/get_defaults.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def get_defaults(_facts)
8888
tmp_dir = '/tmp/'
8989
tmp_dir_config = true
9090
version = :undef
91+
keyring = '/etc/apt/keyrings/docker.gpg'
9192

9293
if _facts[:os]['family'] == 'windows'
9394
compose_install_path = "#{_facts['docker_program_files_path']}/Docker"
@@ -487,5 +488,6 @@ def get_defaults(_facts)
487488
'tmp_dir_config' => tmp_dir_config,
488489
'use_upstream_package_source' => use_upstream_package_source,
489490
'version' => version,
491+
'keyring' => keyring,
490492
}
491493
end

spec/shared_examples/repos.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
key_source = values['package_key_source']
1212
key_check_source = values['package_key_check_source']
1313
architecture = facts[:os]['architecture']
14+
keyring = params['keyring']
1415

1516
unless params['prerequired_packages'].empty?
1617
params['prerequired_packages'].each do |package|
@@ -29,13 +30,21 @@
2930
if params['use_upstream_package_source']
3031
# check if debian version is atleast 10 and ubuntu version is atleast 22
3132
if ( facts[:operatingsystem] == 'Debian' and facts[:operatingsystemrelease] =~ /1[0-9]/ ) or ( facts[:operatingsystem] == 'Ubuntu' and facts[:operatingsystemrelease] =~ /2[2-9]/ )
33+
it {
34+
is_expected.to contain_file(keyring).with(
35+
'ensure' => 'file',
36+
'mode' => '0644',
37+
'owner' => 'root',
38+
'group' => 'root',
39+
)
40+
}
3241
it {
3342
is_expected.to contain_apt__source('docker').with(
3443
'location' => location,
3544
'architecture' => architecture,
3645
'release' => release,
3746
'repos' => package_repos,
38-
'keyring' => '/etc/apt/keyrings/docker.gpg',
47+
'keyring' => keyring,
3948
'include' => {
4049
'src' => false,
4150
},

0 commit comments

Comments
 (0)