summaryrefslogtreecommitdiff
path: root/spec/unit/resource_spec.rb
diff options
context:
space:
mode:
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2014-10-19 11:03:39 +0100
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2014-10-19 11:03:39 +0100
commitb266ca180c803887c2d41342840279c90ba6e931 (patch)
treeb88005e061c592231eda088e7d95c11fb7804c54 /spec/unit/resource_spec.rb
parent9b3e925188a41bbea954429ac81ffdf65e936eda (diff)
downloadchef-b266ca180c803887c2d41342840279c90ba6e931.tar.gz
Fix value of retries shown in the error report.
Fixes #2258. Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Diffstat (limited to 'spec/unit/resource_spec.rb')
-rw-r--r--spec/unit/resource_spec.rb34
1 files changed, 28 insertions, 6 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index bcc91d52bc..584ec8175c 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -394,22 +394,44 @@ describe Chef::Resource do
end
describe "retries" do
+ before do
+ @retriable_resource = Chef::Resource::Cat.new("precious", @run_context)
+ @retriable_resource.provider = Chef::Provider::SnakeOil
+ @retriable_resource.action = :purr
+
+ @node.automatic_attrs[:platform] = "fubuntu"
+ @node.automatic_attrs[:platform_version] = '10.04'
+ end
+
it "should default to not retrying if a provider fails for a resource" do
- @resource.retries.should == 0
+ @retriable_resource.retries.should == 0
end
it "should allow you to set how many retries a provider should attempt after a failure" do
- @resource.retries(2)
- @resource.retries.should == 2
+ @retriable_resource.retries(2)
+ @retriable_resource.retries.should == 2
end
it "should default to a retry delay of 2 seconds" do
- @resource.retry_delay.should == 2
+ @retriable_resource.retry_delay.should == 2
end
it "should allow you to set the retry delay" do
- @resource.retry_delay(10)
- @resource.retry_delay.should == 10
+ @retriable_resource.retry_delay(10)
+ @retriable_resource.retry_delay.should == 10
+ end
+
+ it "should keep given value of retries intact after the provider fails for a resource" do
+ @retriable_resource.retries(3)
+ @retriable_resource.retry_delay(0) # No need to wait.
+
+ provider = Chef::Provider::SnakeOil.new(@retriable_resource, @run_context)
+ Chef::Provider::SnakeOil.stub(:new).and_return(provider)
+ provider.stub(:action_purr).and_raise
+
+ @retriable_resource.should_receive(:sleep).exactly(3).times
+ expect { @retriable_resource.run_action(:purr) }.to raise_error
+ @retriable_resource.retries.should == 3
end
end