Skip to content

Commit

Permalink
Fix idempotence when installing the Windows package
Browse files Browse the repository at this point in the history
The Windows package now includes a version string in its name, not just
"Chef Development Kit", so it was reinstalling on every Chef run.
  • Loading branch information
hartmantis committed Jul 22, 2016
1 parent 82c746b commit d071720
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions libraries/resource_chef_dk_app_windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class ChefDkAppWindows < ChefDkApp
action :install do
case new_resource.source
when :direct
package 'Chef Development Kit' do
ver = new_resource.version || package_metadata[:version]
package "Chef Development Kit v#{ver}" do
source package_metadata[:url]
checksum package_metadata[:sha256]
end
Expand All @@ -45,7 +46,8 @@ class ChefDkAppWindows < ChefDkApp
version new_resource.version unless new_resource.version.nil?
end
else
package 'Chef Development Kit' do
ver = new_resource.version || package_metadata[:version]
package "Chef Development Kit v#{ver}" do
source new_resource.source.to_s
checksum new_resource.checksum unless new_resource.checksum.nil?
end
Expand Down
6 changes: 4 additions & 2 deletions spec/resources/chef_dk_app/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

shared_examples_for 'any property set' do
it 'installs the correct Chef-DK package' do
expect(chef_run).to install_package('Chef Development Kit').with(
pkg = "Chef Development Kit v#{version || '1.2.3'}"
expect(chef_run).to install_package(pkg).with(
source: "http://example.com/#{channel || 'stable'}/chefdk",
checksum: '1234'
)
Expand Down Expand Up @@ -76,7 +77,8 @@
include_context description

it 'installs the correct Chef-DK package' do
expect(chef_run).to install_package('Chef Development Kit').with(
pkg = "Chef Development Kit v#{version || '1.2.3'}"
expect(chef_run).to install_package(pkg).with(
source: 'https://example.biz/cdk',
checksum: '12345'
)
Expand Down

0 comments on commit d071720

Please sign in to comment.