mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
spec fixes and tests for the new monitor functions
This commit is contained in:
parent
c937fe3566
commit
e2a755b664
3 changed files with 45 additions and 25 deletions
|
@ -41,6 +41,28 @@ module Fog
|
|||
raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}")
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_monitor_defaults!(monitor)
|
||||
if monitor[:http_headers].is_a?(String)
|
||||
monitor[:http_headers] = [ monitor[:http_headers] ]
|
||||
end
|
||||
|
||||
unless monitor[:retries]
|
||||
monitor[:retries] = 3
|
||||
end
|
||||
|
||||
unless monitor[:response_timeout]
|
||||
monitor[:response_timeout] = 2
|
||||
end
|
||||
|
||||
unless monitor[:down_time]
|
||||
monitor[:down_time] = 30
|
||||
end
|
||||
|
||||
unless monitor[:interval]
|
||||
monitor[:interval] = 5
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
|
@ -97,27 +119,6 @@ module Fog
|
|||
}
|
||||
end
|
||||
|
||||
def ensure_monitor_defaults!(monitor)
|
||||
if monitor[:http_headers].is_a?(String)
|
||||
monitor[:http_headers] = [ monitor[:http_headers] ]
|
||||
end
|
||||
|
||||
unless monitor[:retries]
|
||||
monitor[:retries] = 3
|
||||
end
|
||||
|
||||
unless monitor[:response_timeout]
|
||||
monitor[:response_timeout] = 2
|
||||
end
|
||||
|
||||
unless monitor[:down_time]
|
||||
monitor[:down_time] = 30
|
||||
end
|
||||
|
||||
unless monitor[:interval]
|
||||
monitor[:interval] = 5
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
|
|
@ -30,6 +30,10 @@ def arrayify(item)
|
|||
item.is_a?(Array) ? item : [ item ]
|
||||
end
|
||||
|
||||
def ecloud_disabled_default_monitor
|
||||
{:url_send_string=>nil, :receive_string=>nil, :response_timeout=>2, :retries=>3, :is_enabled=>"true", :down_time=>30, :type=>"Disabled", :http_headers=>nil, :interval=>5, :downtime=>nil}
|
||||
end
|
||||
|
||||
shared_examples_for "all responses" do
|
||||
it { should be_an_instance_of Excon::Response }
|
||||
it { should respond_to :body }
|
||||
|
|
|
@ -76,11 +76,26 @@ if Fog.mocking?
|
|||
end
|
||||
end
|
||||
|
||||
context "with a disabled monitor" do
|
||||
describe "disable monitoring via #monitor=" do
|
||||
specify do
|
||||
expect { subject.monitor = {:type => "Disabled", :is_enabled => "true" }; subject.save }.to
|
||||
change {@mock_service[:monitor]}.from(nil).
|
||||
to({:url_send_string=>nil, :http_headers=>nil, :receive_string=>nil, :interval=>nil, :is_enabled=>"true", :type=>"Disabled", :response_timeout=>nil, :downtime=>nil, :retries=>nil})
|
||||
expect { subject.monitor = {:type => "Disabled", :is_enabled => "true" }; subject.save }.to change {subject.monitor}.from(nil).to(ecloud_disabled_default_monitor)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "disable monitoring via #disable_monitor" do
|
||||
specify do
|
||||
expect { subject.disable_monitor }.to change {subject.monitor}.from(nil).to(ecloud_disabled_default_monitor)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a disabled monitor" do
|
||||
before { subject.disable_monitor }
|
||||
|
||||
describe "enable ping monitoring via #enable_ping_monitor" do
|
||||
specify do
|
||||
expect { subject.enable_ping_monitor }.to change {subject.monitor}.from(ecloud_disabled_default_monitor).to(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue