summaryrefslogtreecommitdiff
path: root/spec/unit/util
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2014-09-03 12:52:32 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2014-09-19 12:48:08 -0700
commitce46528db4c9a7f06a34d16ee37017a59e8aab73 (patch)
treec200590d2c65535948cf754e9808082f4520d69d /spec/unit/util
parent7bf9673185640d1b315193bb0f9d6be3492c05d3 (diff)
downloadchef-ce46528db4c9a7f06a34d16ee37017a59e8aab73.tar.gz
lcm parser is a lot more forgiving
Diffstat (limited to 'spec/unit/util')
-rw-r--r--spec/unit/util/dsc/lcm_output_parser_spec.rb45
1 files changed, 18 insertions, 27 deletions
diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb
index 05aa072a94..23a3dbd3ec 100644
--- a/spec/unit/util/dsc/lcm_output_parser_spec.rb
+++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb
@@ -103,49 +103,40 @@ EOF
end
context 'Incorrectly formatted output from LCM' do
- it 'should raise an exception if a set 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 Set ]
-logtype: [machinename]: LCM: [ End Set ]
logtype: [machinename]: LCM: [ End Test ]
-logtype: [machinename]: LCM: [ End Resource ] [name]
-logtype: [machinename]: LCM: [ End Set ]
-EOF
- expect { Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) }.to(raise_error(
- Chef::Util::DSC::LocalConfigurationManager::Parser::ParseException))
- end
-
- it 'should raise an exception if a test is found inside a test' do
- str = <<EOF
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ Start Test ]
+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: [ End Test ]
-logtype: [machinename]: LCM: [ End Resource ] [name]
+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 allow missing a [End Resource] when its the last one and still find all the resource' do
+ 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 Test ]
logtype: [machinename]: LCM: [ End Test ]
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 Resource ]
logtype: [machinename]: LCM: [ End Set ]
EOF
@@ -154,13 +145,12 @@ EOF
resources[1].changes_state?.should be_true
end
- it 'should allow missing a [End Resource] when its the first one and still find all the resource' do
+ it 'should allow missing set and end resource and assume an unconverged resource in this case' do
str = <<-EOF
logtype: [machinename]: LCM: [ Start Set ]
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 ]
@@ -169,10 +159,11 @@ logtype: [machinename]: LCM: [ End Set ]
logtype: [machinename]: LCM: [ End Resource ]
logtype: [machinename]: LCM: [ End Set ]
EOF
-
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
- resources[0].changes_state?.should be_false
+ resources[0].changes_state?.should be_true
+ resources[0].name.should eql('[name]')
resources[1].changes_state?.should be_true
+ resources[1].name.should eql('[name2]')
end
end
end