summaryrefslogtreecommitdiff
path: root/spec/unit/util
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2014-08-22 14:49:53 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2014-09-19 12:47:34 -0700
commit31f0e0a53d82d4cab7b607e367dec5ec6104847c (patch)
tree0e9125f44d2a004715261673878a055d2e8ef68a /spec/unit/util
parent7e5daa0ef8486275c82e694d1862d56b5a21f417 (diff)
downloadchef-31f0e0a53d82d4cab7b607e367dec5ec6104847c.tar.gz
Deal with LCM failing when a resource does not support WhatIf
Diffstat (limited to 'spec/unit/util')
-rw-r--r--spec/unit/util/dsc/lcm_output_parser_spec.rb48
1 files changed, 30 insertions, 18 deletions
diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb
index 8ed305827c..802c0ea429 100644
--- a/spec/unit/util/dsc/lcm_output_parser_spec.rb
+++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb
@@ -133,34 +133,46 @@ EOF
Chef::Util::DSC::LocalConfigurationManager::Parser::ParseException))
end
- it 'should raise an exception if a resource is found inside a test' do
- str = <<EOF
+ it 'should allow missing a [End Resource] when its the last one and still find all the resource' do
+ str = <<-EOF
logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
+logtype: [machinename]: LCM: [ Start Resource ] [name]
logtype: [machinename]: LCM: [ Start Test ]
-logtype: [machinename]: LCM: [ Start Resource ]
-logtype: [machinename]: LCM: [ End Resource ]
logtype: [machinename]: LCM: [ End Test ]
-logtype: [machinename]: LCM: [ End Resource ] [name]
+logtype: [machinename]: LCM: [ Skip Set ]
+logtype: [machinename]: LCM: [ End Resource ]
+logtype: [machinename]: LCM: [ Start Resource ] [name2]
+logtype: [machinename]: LCM: [ Start Test ]
+logtype: [machinename]: LCM: [ End Test ]
+logtype: [machinename]: LCM: [ Start Set ]
+logtype: [machinename]: LCM: [ End Set ]
logtype: [machinename]: LCM: [ End Set ]
EOF
- expect { Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) }.to(raise_error(
- Chef::Util::DSC::LocalConfigurationManager::Parser::ParseException))
+
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources[0].changes_state?.should be_false
+ resources[1].changes_state?.should be_true
end
- it 'should raise an exception if a resource is found inside a resource' do
- str = <<EOF
+ it 'should allow missing a [End Resource] when its the first one and still find all the resource' do
+ str = <<-EOF
logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ Start Resource ]
-logtype: [machinename]: LCM: [ End Resource ]
-logtype: [machinename]: LCM: [ End Resource ] [name]
+logtype: [machinename]: LCM: [ Start Resource ] [name]
+logtype: [machinename]: LCM: [ Start Test ]
+logtype: [machinename]: LCM: [ End Test ]
+logtype: [machinename]: LCM: [ Skip Set ]
+logtype: [machinename]: LCM: [ Start Resource ] [name2]
+logtype: [machinename]: LCM: [ Start Test ]
+logtype: [machinename]: LCM: [ End Test ]
+logtype: [machinename]: LCM: [ Start Set ]
+logtype: [machinename]: LCM: [ End Set ]
+logtype: [machinename]: LCM: [ End Resource ]
logtype: [machinename]: LCM: [ End Set ]
EOF
- expect { Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) }.to(raise_error(
- Chef::Util::DSC::LocalConfigurationManager::Parser::ParseException))
- end
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources[0].changes_state?.should be_false
+ resources[1].changes_state?.should be_true
+ end
end
-
end