diff --git a/lib/fog/aws/elasticache.rb b/lib/fog/aws/elasticache.rb index b67b90094..b05a438ab 100644 --- a/lib/fog/aws/elasticache.rb +++ b/lib/fog/aws/elasticache.rb @@ -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 diff --git a/lib/fog/aws/requests/elasticache/create_cache_parameter_group.rb b/lib/fog/aws/requests/elasticache/create_cache_parameter_group.rb index cb9ffdab7..ae8ab3499 100644 --- a/lib/fog/aws/requests/elasticache/create_cache_parameter_group.rb +++ b/lib/fog/aws/requests/elasticache/create_cache_parameter_group.rb @@ -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 diff --git a/lib/fog/aws/requests/elasticache/delete_cache_parameter_group.rb b/lib/fog/aws/requests/elasticache/delete_cache_parameter_group.rb index 3704fb741..83c54621b 100644 --- a/lib/fog/aws/requests/elasticache/delete_cache_parameter_group.rb +++ b/lib/fog/aws/requests/elasticache/delete_cache_parameter_group.rb @@ -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 diff --git a/lib/fog/aws/requests/elasticache/describe_cache_parameter_groups.rb b/lib/fog/aws/requests/elasticache/describe_cache_parameter_groups.rb index f3423fc7a..d1864f123 100644 --- a/lib/fog/aws/requests/elasticache/describe_cache_parameter_groups.rb +++ b/lib/fog/aws/requests/elasticache/describe_cache_parameter_groups.rb @@ -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 diff --git a/tests/aws/models/elasticache/parameter_groups_tests.rb b/tests/aws/models/elasticache/parameter_groups_tests.rb index 56d7306c8..019627ec8 100644 --- a/tests/aws/models/elasticache/parameter_groups_tests.rb +++ b/tests/aws/models/elasticache/parameter_groups_tests.rb @@ -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