mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Move the timeout to Mock and stop hardcoding.
This commit is contained in:
parent
216b3ded0d
commit
74c4689691
3 changed files with 13 additions and 3 deletions
|
@ -21,6 +21,16 @@ module Fog
|
||||||
@delay
|
@delay
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@timeout = 600
|
||||||
|
def self.timeout
|
||||||
|
@timeout
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.timeout=(new_timeout)
|
||||||
|
raise ArgumentError, "timeout must be non-negative" unless new_timeout >= 0
|
||||||
|
@timeout = new_timeout
|
||||||
|
end
|
||||||
|
|
||||||
def self.delay=(new_delay)
|
def self.delay=(new_delay)
|
||||||
raise ArgumentError, "delay must be non-negative" unless new_delay >= 0
|
raise ArgumentError, "delay must be non-negative" unless new_delay >= 0
|
||||||
@delay = new_delay
|
@delay = new_delay
|
||||||
|
|
|
@ -42,7 +42,7 @@ module Fog
|
||||||
attributes.to_json
|
attributes.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
def wait_for(timeout=600, interval=1, &block)
|
def wait_for(timeout=Fog::Mock.timeout, interval=1, &block)
|
||||||
reload
|
reload
|
||||||
retries = 3
|
retries = 3
|
||||||
Fog.wait_for(timeout, interval) do
|
Fog.wait_for(timeout, interval) do
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Fog
|
module Fog
|
||||||
|
|
||||||
def self.wait_for(timeout=600, interval=1, &block)
|
def self.wait_for(timeout=Fog::Mock.timeout, interval=1, &block)
|
||||||
duration = 0
|
duration = 0
|
||||||
start = Time.now
|
start = Time.now
|
||||||
until yield || duration > timeout
|
until yield || duration > timeout
|
||||||
|
@ -14,4 +14,4 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue