Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure that puppet sets setExplicitly when disabled #361

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/puppet/provider/chocolateyfeature/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def self.get_choco_feature(element)

feature[:ensure] = :disabled
feature[:ensure] = :enabled if enabled
feature[:ensure] = :not_explicit if element.attributes['setExplicitly'].casecmp('false').zero?

Puppet.debug("Loaded feature '#{feature.inspect}'.")

Expand Down
11 changes: 10 additions & 1 deletion spec/unit/puppet/provider/chocolateyfeature/windows_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@

element_name = 'default'
element_enabled = 'true'
element_set_explicitly = 'true'

before :each do
element.add_attributes('name' => element_name, 'enabled' => element_enabled)
element.add_attributes('name' => element_name, 'enabled' => element_enabled, 'setExplicitly' => element_set_explicitly)
end

it 'returns nil feature when element is nil' do
Expand All @@ -177,5 +178,13 @@
feature = provider_class.get_choco_feature(element)
expect(feature[:ensure]).to eq(:disabled)
end

it 'when feature is not set explicitly' do
element.delete_attribute('setExplicitly')
element.add_attribute('setExplicitly', 'false')

feature = provider_class.get_choco_feature(element)
expect(feature[:ensure]).to eq(:not_explicit)
end
end
end