1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

mocking delete_db_instance

This commit is contained in:
Rodrigo Estebanez 2011-11-30 17:19:05 +01:00
parent 735f8ec66c
commit 077ddc41ed
2 changed files with 21 additions and 13 deletions

View file

@ -30,8 +30,24 @@ module Fog
class Mock
def delete_db_snapshot(identifier, snapshot_identifier, skip_snapshot = false)
Fog::Mock.not_implemented
def delete_db_instance(identifier, snapshot_identifier, skip_snapshot = false)
response = Excon::Response.new
unless skip_snapshot
# I don't know how to mock snapshot_identifier
Fog::Logger.warning("snapshot_identifier is not mocked [light_black](#{caller.first})[/]")
end
if server_set = self.data[:servers].delete(identifier)
response.status = 200
response.body = {
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
"DeleteDBInstanceResult" => { "DBInstance" => server_set }
}
response
else
raise Fog::AWS::RDS::NotFound.new("DBInstance #{identifier} not found")
end
end
end

View file

@ -35,21 +35,13 @@ module Fog
def describe_db_instances(identifier=nil, opts={})
response = Excon::Response.new
if identifier
if self.data[:servers].has_key?(identifier)
servers_set = self.data[:servers][identifier]
if server_set = self.data[:servers][identifier]
response.status = 200
response.body = {
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
"DescribeDBInstancesResult" => { "DBInstances" => [servers_set] }
"DescribeDBInstancesResult" => { "DBInstances" => [server_set] }
}
else
response.status = 404
response.body = {
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
"DescribeDBInstancesResult" => { "DBInstances" => 'DBInstanceNotFound' }
}
raise Fog::AWS::RDS::NotFound.new("DBInstance #{identifier} not found")
end