summaryrefslogtreecommitdiff
path: root/spec/unit/provider/dsc_resource_spec.rb
diff options
context:
space:
mode:
authorSteven Murawski <steven.murawski@gmail.com>2015-11-13 17:56:21 -0600
committerSteven Murawski <steven.murawski@gmail.com>2015-11-18 10:18:50 -0600
commit9f6a1bbe020c2664fbe96f18ed8d5861a9e3da84 (patch)
treeaad306daf0b56602f050204747e24b1bfece1cec /spec/unit/provider/dsc_resource_spec.rb
parentfbdf03d3c174f1c2309a497efcf92227e191fdc0 (diff)
downloadchef-9f6a1bbe020c2664fbe96f18ed8d5861a9e3da84.tar.gz
WMF 5 RTM and Win 10 Threshold 2 allow the RefreshMode to be enabled.
Diffstat (limited to 'spec/unit/provider/dsc_resource_spec.rb')
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb103
1 files changed, 62 insertions, 41 deletions
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index b95b1d7bcf..46cdbd93a6 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -41,55 +41,76 @@ describe Chef::Provider::DscResource do
end
context 'when Powershell supports Invoke-DscResource' do
+
+ context 'when RefreshMode is not set to Disabled' do
+ context 'and the WMF 5 is a preview release' do
+ let (:node) {
+ node = Chef::Node.new
+ node.automatic[:languages][:powershell][:version] = '5.0.10018.0'
+ node
+ }
+ it 'raises an exception' do
+ expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(false)
+ expect { provider.run_action(:run) }.to raise_error(
+ Chef::Exceptions::ProviderNotFound, /Disabled/)
+ end
+ end
+ context 'and the WMF is 5 RTM or newer' do
+ let (:node) {
+ node = Chef::Node.new
+ node.automatic[:languages][:powershell][:version] = '5.0.10586.0'
+ node
+ }
+ it 'does not raises an exception' do
+ expect(provider).to receive(:test_resource)
+ expect(provider).to receive(:set_resource)
+ expect(provider).to receive(:reboot_if_required)
+ expect { provider.run_action(:run) }.to_not raise_error
+ end
+ end
+ end
+ end
+
+ context 'when the LCM supports Invoke-DscResource' do
let (:node) {
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = '5.0.10018.0'
node
}
- context 'when RefreshMode is not set to Disabled' do
- it 'raises an exception' do
- expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(false)
- expect { provider.run_action(:run) }.to raise_error(
- Chef::Exceptions::ProviderNotFound, /Disabled/)
- end
+ it 'does not update the resource if it is up to date' do
+ expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
+ expect(provider).to receive(:test_resource).and_return(true)
+ provider.run_action(:run)
+ expect(resource).not_to be_updated
end
- context 'when RefreshMode is set to Disabled' do
- it 'does not update the resource if it is up to date' do
- expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
- expect(provider).to receive(:test_resource).and_return(true)
- provider.run_action(:run)
- expect(resource).not_to be_updated
- end
-
- it 'converges the resource if it is not up to date' do
- expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
- expect(provider).to receive(:test_resource).and_return(false)
- expect(provider).to receive(:set_resource)
- provider.run_action(:run)
- expect(resource).to be_updated
- end
-
- it 'flags the resource as reboot required when required' do
- expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
- expect(provider).to receive(:test_resource).and_return(false)
- expect(provider).to receive(:invoke_resource).
- and_return(double(:stdout => '', :return_value =>nil))
- expect(provider).to receive(:return_dsc_resource_result).and_return(true)
- expect(provider).to receive(:create_reboot_resource)
- provider.run_action(:run)
- end
-
- it 'does not flag the resource as reboot required when not required' do
- expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
- expect(provider).to receive(:test_resource).and_return(false)
- expect(provider).to receive(:invoke_resource).
- and_return(double(:stdout => '', :return_value =>nil))
- expect(provider).to receive(:return_dsc_resource_result).and_return(false)
- expect(provider).to_not receive(:create_reboot_resource)
- provider.run_action(:run)
- end
+ it 'converges the resource if it is not up to date' do
+ expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
+ expect(provider).to receive(:test_resource).and_return(false)
+ expect(provider).to receive(:set_resource)
+ provider.run_action(:run)
+ expect(resource).to be_updated
+ end
+
+ it 'flags the resource as reboot required when required' do
+ expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
+ expect(provider).to receive(:test_resource).and_return(false)
+ expect(provider).to receive(:invoke_resource).
+ and_return(double(:stdout => '', :return_value =>nil))
+ expect(provider).to receive(:return_dsc_resource_result).and_return(true)
+ expect(provider).to receive(:create_reboot_resource)
+ provider.run_action(:run)
+ end
+
+ it 'does not flag the resource as reboot required when not required' do
+ expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
+ expect(provider).to receive(:test_resource).and_return(false)
+ expect(provider).to receive(:invoke_resource).
+ and_return(double(:stdout => '', :return_value =>nil))
+ expect(provider).to receive(:return_dsc_resource_result).and_return(false)
+ expect(provider).to_not receive(:create_reboot_resource)
+ provider.run_action(:run)
end
end
end \ No newline at end of file