summaryrefslogtreecommitdiff
path: root/spec/unit/provider/package_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-06-02 16:36:46 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-06-02 18:52:12 -0700
commit23e3c799803ac1800149e27271c6168539cea25e (patch)
treec6394473fc32f9b30b50a309de765940a21d2c8c /spec/unit/provider/package_spec.rb
parent025cabb7158fb02a89250ef91cc94ce3b3c38648 (diff)
downloadchef-23e3c799803ac1800149e27271c6168539cea25e.tar.gz
fix package timeout attribute
updates all the shell_out calls to respect the timeout which is passed on the new_resource. the old `Chef::Config` yum timeout values are still respected and will override the default. the default of 900 seconds is preserved.
Diffstat (limited to 'spec/unit/provider/package_spec.rb')
-rw-r--r--spec/unit/provider/package_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb
index c6ec0fb3cb..432d968906 100644
--- a/spec/unit/provider/package_spec.rb
+++ b/spec/unit/provider/package_spec.rb
@@ -704,4 +704,38 @@ describe "Chef::Provider::Package - Multi" do
expect(@new_resource).not_to be_updated_by_last_action
end
end
+
+ describe "shell_out helpers" do
+ [ :shell_out_with_timeout, :shell_out_with_timeout! ].each do |method|
+ stubbed_method = method == :shell_out_with_timeout! ? :shell_out! : :shell_out
+ [ %w{command arg1 arg2}, "command arg1 arg2" ].each do |command|
+ it "#{method} defaults to 900 seconds" do
+ expect(@provider).to receive(stubbed_method).with(*command, timeout: 900)
+ @provider.send(method, *command)
+ end
+ it "#{method} overrides the default timeout with its options" do
+ expect(@provider).to receive(stubbed_method).with(*command, timeout: 1)
+ @provider.send(method, *command, timeout: 1)
+ end
+ it "#{method} overrides both timeouts with the new_resource.timeout" do
+ @new_resource.timeout(99)
+ expect(@provider).to receive(stubbed_method).with(*command, timeout: 99)
+ @provider.send(method, *command, timeout: 1)
+ end
+ it "#{method} defaults to 900 seconds and preserves options" do
+ expect(@provider).to receive(stubbed_method).with(*command, env: nil, timeout: 900)
+ @provider.send(method, *command, env: nil)
+ end
+ it "#{method} overrides the default timeout with its options and preserves options" do
+ expect(@provider).to receive(stubbed_method).with(*command, timeout: 1, env: nil)
+ @provider.send(method, *command, timeout: 1, env: nil)
+ end
+ it "#{method} overrides both timeouts with the new_resource.timeout and preseves options" do
+ @new_resource.timeout(99)
+ expect(@provider).to receive(stubbed_method).with(*command, timeout: 99, env: nil)
+ @provider.send(method, *command, timeout: 1, env: nil)
+ end
+ end
+ end
+ end
end