Skip to content

Commit

Permalink
Add additional unit-test; configure inheritance of param
Browse files Browse the repository at this point in the history
  • Loading branch information
vegaaz committed Jan 4, 2023
1 parent b3d5f7c commit 5373dea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
'docker_msft_provider_version' => '123',
'nuget_package_provider_version' => '41',
},
'with keyring set to optional path' => {
'keyring' => '/root/keyrings/docker.gpg',
},
}

describe 'docker', type: :class do
Expand Down Expand Up @@ -180,6 +183,7 @@
'tmp_dir' => defaults['tmp_dir'],
'use_upstream_package_source' => defaults['use_upstream_package_source'],
'version' => defaults['version'],
'keyring' => defaults['keyring']
}.merge(default_params).merge(local_params)

let(:facts) do
Expand Down
2 changes: 2 additions & 0 deletions spec/helper/get_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def get_defaults(_facts)
tmp_dir = '/tmp/'
tmp_dir_config = true
version = :undef
keyring = '/etc/apt/keyrings/docker.gpg'

if _facts[:os]['family'] == 'windows'
compose_install_path = "#{_facts['docker_program_files_path']}/Docker"
Expand Down Expand Up @@ -487,5 +488,6 @@ def get_defaults(_facts)
'tmp_dir_config' => tmp_dir_config,
'use_upstream_package_source' => use_upstream_package_source,
'version' => version,
'keyring' => keyring,
}
end
11 changes: 10 additions & 1 deletion spec/shared_examples/repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
key_source = values['package_key_source']
key_check_source = values['package_key_check_source']
architecture = facts[:os]['architecture']
keyring = params['keyring']

unless params['prerequired_packages'].empty?
params['prerequired_packages'].each do |package|
Expand All @@ -29,13 +30,21 @@
if params['use_upstream_package_source']
# check if debian version is atleast 10 and ubuntu version is atleast 22
if ( facts[:operatingsystem] == 'Debian' and facts[:operatingsystemrelease] =~ /1[0-9]/ ) or ( facts[:operatingsystem] == 'Ubuntu' and facts[:operatingsystemrelease] =~ /2[2-9]/ )
it {
is_expected.to contain_file(keyring).with(
'ensure' => 'file',
'mode' => '0644',
'owner' => 'root',
'group' => 'root',
)
}
it {
is_expected.to contain_apt__source('docker').with(
'location' => location,
'architecture' => architecture,
'release' => release,
'repos' => package_repos,
'keyring' => '/etc/apt/keyrings/docker.gpg',
'keyring' => keyring,
'include' => {
'src' => false,
},
Expand Down

0 comments on commit 5373dea

Please sign in to comment.