diff --git a/lib/fog/rackspace/requests/monitoring/update_alarm.rb b/lib/fog/rackspace/requests/monitoring/update_alarm.rb index a4348e57a..950cc3e3e 100644 --- a/lib/fog/rackspace/requests/monitoring/update_alarm.rb +++ b/lib/fog/rackspace/requests/monitoring/update_alarm.rb @@ -3,15 +3,46 @@ module Fog class Monitoring class Real - def update_alarm(entity_id, id, options) + def update_alarm(entity_id, alarm_id, options) request( :body => JSON.encode(options), :expects => [204], :method => 'PUT', - :path => "entities/#{entity_id}/alarms/#{id}" + :path => "entities/#{entity_id}/alarms/#{alarm_id}" ) end end + + class Mock + + def update_alarm(entity_id, alarm_id, options) + + account_id = Fog::Mock.random_numbers(6).to_s + + if entity_id == -1 || alarm_id == -1 || options[:testing] + raise Fog::Rackspace::Monitoring::NotFound + end + + response = Excon::Response.new + response.status = 204 + response.body = "" + response.headers = { + "Date" => Time.now.utc.to_s, + "Location" => "https://monitoring.api.rackspacecloud.com/v1.0/" + account_id + "/entities/" + entity_id.to_s + "/alarms/" + alarm_id, + "X-Object-ID" => alarm_id, + "X-RateLimit-Limit" => "50000", + "X-RateLimit-Remaining" => "47877", + "X-RateLimit-Window" => "24 hours", + "X-RateLimit-Type" => "global", + "X-Response-Id" => "laolsgggopsnfksdovnsv", + "X-LB" => "dfw1-maas-prod-api1", + "Content-Length" => "0", + "Content-Type" => "text/plain" + } + response.remote_ip = Fog::Rackspace::MockData.ipv4_address + response + end + end end end end diff --git a/tests/rackspace/requests/monitoring/alarm_tests.rb b/tests/rackspace/requests/monitoring/alarm_tests.rb index 17c18e9a9..d5bcc6710 100644 --- a/tests/rackspace/requests/monitoring/alarm_tests.rb +++ b/tests/rackspace/requests/monitoring/alarm_tests.rb @@ -19,7 +19,6 @@ Shindo.tests('Fog::Rackspace::Monitoring | alarm_tests', ['rackspace','rackspace response end tests('#update alarm').formats(DATA_FORMAT) do - pending if Fog.mocking? options = { :label => "Bar"} account.update_alarm(entity_id,alarm_id,options).data end @@ -39,7 +38,6 @@ Shindo.tests('Fog::Rackspace::Monitoring | alarm_tests', ['rackspace','rackspace account.create_alarm(entity_id, {:type => ""}) end tests('#fail to update invalid alarm(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do - pending if Fog.mocking? options = { :testing => "Bar" } response = account.update_alarm(-1,-1,options) end