summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2016-09-30 12:07:39 -0400
committerGitHub <noreply@github.com>2016-09-30 12:07:39 -0400
commitf44960c65420e1af5afe85de12ef1e9849999356 (patch)
treeb993384424de6701c94f88efc4695d1fee59bb23
parentc227b21dbe91d530cea9e3dfd3837a577392b14b (diff)
parent5536af82e9d6e825d988ce769bc42a61cfefcb32 (diff)
downloadchef-f44960c65420e1af5afe85de12ef1e9849999356.tar.gz
Merge pull request #5377 from MsysTechnologiesllc/nim/dsc_failure_reported_warning
Invalid `dsc_scripts` should fail the run
-rw-r--r--lib/chef/util/dsc/local_configuration_manager.rb2
-rw-r--r--spec/unit/util/dsc/local_configuration_manager_spec.rb14
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb
index 741c6a5898..d837a16185 100644
--- a/lib/chef/util/dsc/local_configuration_manager.rb
+++ b/lib/chef/util/dsc/local_configuration_manager.rb
@@ -74,7 +74,7 @@ class Chef::Util::DSC
def lcm_command_code(configuration_path, test_only_parameters)
<<-EOH
-$ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configuration_path} -wait -erroraction 'continue' -force #{test_only_parameters}
+$ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configuration_path} -wait -erroraction 'stop' -force #{test_only_parameters}
EOH
end
diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb
index 45fe8df40d..3f1210dbf1 100644
--- a/spec/unit/util/dsc/local_configuration_manager_spec.rb
+++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb
@@ -59,10 +59,6 @@ EOH
allow(lcm).to receive(:run_configuration_cmdlet).and_return(lcm_status)
end
context "that returns successfully" do
- before(:each) do
- allow(lcm).to receive(:run_configuration_cmdlet).and_return(lcm_status)
- end
-
let(:lcm_standard_output) { normal_lcm_output }
let(:lcm_standard_error) { nil }
let(:lcm_cmdlet_success) { true }
@@ -138,4 +134,14 @@ EOH
expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub("CimException", "ArgumentException"))).to be(false)
end
end
+
+ describe "#run_configuration_cmdlet" do
+ context "when invalid dsc script is given" do
+ it "raises exception" do
+ configuration_document = "invalid-config"
+ shellout_flags = { :cwd => nil, :environment => nil, :timeout => nil }
+ expect { lcm.send(:run_configuration_cmdlet, configuration_document, true, shellout_flags) }.to raise_error(Chef::Exceptions::PowershellCmdletException)
+ end
+ end
+ end
end