Skip to content

Commit

Permalink
update install_spec test
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettrowell committed Oct 16, 2024
1 parent 40b3d22 commit b3c3d6c
Showing 1 changed file with 65 additions and 16 deletions.
81 changes: 65 additions & 16 deletions spec/classes/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
end

context 'contains install.pp' do
['c:\local_folder', 'C:\\ProgramData\\chocolatey'].each do |param_value|
context "choco_install_location => #{param_value}" do
let(:params) { { choco_install_location: param_value } }
let(:exec_environment) { catalogue.resource('exec', 'install_chocolatey_official').send(:parameters)[:environment] }

it { is_expected.to contain_exec('install_chocolatey_official').with_creates("#{param_value}\\bin\\choco.exe") }
['c:\local_folder', 'C:\\ProgramData\\chocolatey', 'C:\Program Files\chocolatey'].each do |choco_install_path|
context "choco_install_location => #{choco_install_path}" do
let(:params) { { choco_install_location: choco_install_path } }

it { is_expected.to contain_exec('install_chocolatey_official').with_creates("#{choco_install_path}\\bin\\choco.exe") }
it { expect(exec_environment).to include("ChocolateyInstall=#{choco_install_path}") }
it { is_expected.to contain_registry_value('ChocolateyInstall environment value').with_data(choco_install_path) }
end
end

Expand All @@ -32,27 +36,72 @@
context 'use_7zip => false' do
let(:params) { { use_7zip: false } }

it {
expect(subject).not_to contain_file('C:\Temp\7za.exe')
}
it { expect(exec_environment).to include('chocolateyUseWindowsCompression=true') }
end

context 'use_7zip => true' do
let(:params) { { use_7zip: true } }

context 'seven_zip_download_url default' do
let(:params) { { use_7zip: true } }
it { expect(exec_environment).to include('chocolateyUseWindowsCompression=false') }
end

it { is_expected.to contain_file('C:\Temp\7za.exe').with_source('https://chocolatey.org/7za.exe') }
['https://packages.organization.net/7za.exe'].each do |seven_zip_url|
context "seven_zip_download_url => '#{seven_zip_url}'" do
let(:params) do
super().merge({ seven_zip_download_url: seven_zip_url })
end

it { is_expected.to contain_exec('install_chocolatey_official').with_command(%r{.*Request-File -Url #{seven_zip_url}.*}) }
end
end
end

['http://proxy.megacorp.com:3128'].each do |proxy_url|
context "install_proxy => '#{proxy_url}'" do
let(:params) { { install_proxy: proxy_url } }

it { expect(exec_environment).to include("chocolateyProxyLocation=#{proxy_url}") }

context 'install_proxy_user => \'Bob\'' do
let(:params) do
super().merge({ install_proxy_user: 'Bob' })
end

it { expect(exec_environment).to include('chocolateyProxyUser=Bob') }
end

context "seven_zip_download_url => 'https://packages.organization.net/7za.exe'" do
let(:params) do
{
use_7zip: true,
seven_zip_download_url: 'https://packages.organization.net/7za.exe'
}
context 'install_proxy_password => \'SomeP@$$\'' do
let(:params) do
super().merge({ install_proxy_password: sensitive('SomeP@$$') })
end

it { expect(exec_environment).to include('chocolateyProxyPassword=SomeP@$$') }
end

context 'install_proxy_ignore => true' do
let(:params) do
super().merge({ install_ignore_proxy: true })
end

it { expect(exec_environment).to include('chocolateyIgnoreProxy=true') }
end
end
end

['https://internalurl/to/chocolatey.nupkg'].each do |param_value|
context "download_url => '#{param_value}'" do
let(:params) { { chocolatey_download_url: param_value } }

it { expect(exec_environment).to include("chocolateyDownloadUrl=#{param_value}") }
end
end

['C:/temp'].each do |param_value|
context "install_tempdir => '#{param_value}'" do
let(:params) { { install_tempdir: param_value } }

it { is_expected.to contain_file('C:\Temp\7za.exe').with_source('https://packages.organization.net/7za.exe') }
it { expect(exec_environment).to include("TEMP=#{param_value}") }
end
end
end
Expand Down

0 comments on commit b3c3d6c

Please sign in to comment.