From b464890d6a717c488c3f7ad83e0ff06034278627 Mon Sep 17 00:00:00 2001 From: dheerajd-msys Date: Fri, 31 Jul 2020 09:25:28 +0530 Subject: additional tests Signed-off-by: dheerajd-msys --- .../unit/resource/windows_feature_powershell_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/unit/resource/windows_feature_powershell_spec.rb b/spec/unit/resource/windows_feature_powershell_spec.rb index fbe9be3bf0..ef2da38334 100644 --- a/spec/unit/resource/windows_feature_powershell_spec.rb +++ b/spec/unit/resource/windows_feature_powershell_spec.rb @@ -22,6 +22,7 @@ describe Chef::Resource::WindowsFeaturePowershell do let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } let(:resource) { Chef::Resource::WindowsFeaturePowershell.new(%w{SNMP DHCP}, run_context) } + let(:provider) { resource.provider_for_action(:install) } it "sets resource name as :windows_feature_powershell" do expect(resource.resource_name).to eql(:windows_feature_powershell) @@ -75,4 +76,23 @@ describe Chef::Resource::WindowsFeaturePowershell do resource.feature_name "SNMP, DHCP" expect { resource.action :install }.not_to raise_error end + + it "does not attempt to install features that have been removed" do + node.default["powershell_features_cache"] ||= {} + node.default["powershell_features_cache"]["disabled"] = ["dhcp"] + node.default["powershell_features_cache"]["removed"] = ["snmp"] + resource.feature_name "dhcp, snmp" + + expect(provider.features_to_install).to eq(["dhcp"]) + end + + it "attempts to install features that have been removed when source is set" do + node.default["powershell_features_cache"] ||= {} + node.default["powershell_features_cache"]["disabled"] = ["dhcp"] + node.default["powershell_features_cache"]["removed"] = ["snmp"] + resource.feature_name "dhcp, snmp" + resource.source 'D:\\sources\\sxs' + + expect(provider.features_to_install).to eq(%w{dhcp snmp}) + end end -- cgit v1.2.1