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

[AWS/elasticache] Added mocking for parameter groups

This commit is contained in:
Brian Nelson 2014-02-12 18:10:31 -08:00
parent 91c3b6fc2d
commit 17181ae75c
5 changed files with 59 additions and 10 deletions

View file

@ -139,7 +139,16 @@ module Fog
:clusters => {}, # cache cluster data, indexed by cluster ID
:security_groups => {}, # security groups
:subnet_groups => {},
}
:parameter_groups => {"default.memcached1.4" => { "CacheParameterGroupFamily"=>"memcached1.4",
"Description"=>"Default parameter group for memcached1.4",
"CacheParameterGroupName"=>"default.memcached1.4"
},
"default.redis2.6" => {"CacheParameterGroupFamily"=>"redis2.6",
"Description"=>"Default parameter group for redis2.6",
"CacheParameterGroupName"=>"default.redis2.6"
}
}
}
end
end
end

View file

@ -27,9 +27,25 @@ module Fog
end
class Mock
def create_cache_parameter_group(name, description = name,
family = 'memcached1.4')
Fog::Mock.not_implemented
def create_cache_parameter_group(name, description = name, family = 'memcached1.4')
response = Excon::Response.new
if self.data[:parameter_groups] and self.data[:parameter_groups][name]
raise Fog::AWS::Elasticache::IdentifierTaken.new("Parameter group #{name} already exists")
end
data = {
'CacheParameterGroupName' => name,
'CacheParameterGroupFamily' => family.downcase,
'Description' => description
}
self.data[:parameter_groups][name] = data
response.body = {
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
"CreateCacheParameterGroupResult"=> {"CacheParameterGroup"=> data}
}
response.status = 200
response
end
end
end

View file

@ -23,7 +23,17 @@ module Fog
class Mock
def delete_cache_parameter_group(name)
Fog::Mock.not_implemented
response = Excon::Response.new
if self.data[:parameter_groups].delete(name)
response.status = 200
response.body = {
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
}
response
else
raise Fog::AWS::RDS::NotFound.new("CacheParameterGroup not found: #{name}")
end
end
end
end

View file

@ -26,7 +26,23 @@ module Fog
class Mock
def describe_cache_parameter_groups(name = nil, options = {})
Fog::Mock.not_implemented
response = Excon::Response.new
parameter_set = []
if name
if server = self.data[:parameter_groups][name]
parameter_set << server
else
raise Fog::AWS::Elasticache::NotFound.new("CacheParameterGroup #{name} not found")
end
else
parameter_set = self.data[:parameter_groups].values
end
response.status = 200
response.body = { "CacheParameterGroups" => parameter_set }
response
end
end
end

View file

@ -2,16 +2,14 @@ Shindo.tests('AWS::Elasticache | parameter groups', ['aws', 'elasticache']) do
group_name = 'fog-test'
description = 'Fog Test'
pending if Fog.mocking?
model_tests(
AWS[:elasticache].parameter_groups,
{:id => group_name, :description => description}, false
{:id => group_name, :description => description}, true
)
collection_tests(
AWS[:elasticache].parameter_groups,
{:id => group_name, :description => description}, false
{:id => group_name, :description => description}, true
)
end