diff --git a/lib/fog/aws/elasticache.rb b/lib/fog/aws/elasticache.rb index b448f9bea..e16ca57c1 100644 --- a/lib/fog/aws/elasticache.rb +++ b/lib/fog/aws/elasticache.rb @@ -10,7 +10,7 @@ module Fog request_path 'fog/aws/requests/elasticache' request :create_cache_cluster - #request :delete_cache_cluster + request :delete_cache_cluster request :describe_cache_clusters #request :modify_cache_cluster #request :reboot_cache_cluster diff --git a/lib/fog/aws/requests/elasticache/delete_cache_cluster.rb b/lib/fog/aws/requests/elasticache/delete_cache_cluster.rb new file mode 100644 index 000000000..079923fbe --- /dev/null +++ b/lib/fog/aws/requests/elasticache/delete_cache_cluster.rb @@ -0,0 +1,32 @@ +module Fog + module AWS + class Elasticache + class Real + + require 'fog/aws/parsers/elasticache/describe_cache_clusters' + + # Deletes a Cache Cluster + # + # === Parameter (required): + # * CacheClusterId <~String> - The ID of the cache cluster to delete + # === Returns + # * response <~Excon::Response>: + # * body <~Hash> + def delete_cache_cluster(cluster_id) + request( + 'Action' => 'DeleteCacheCluster', + 'CacheClusterId' => cluster_id, + :parser => Fog::Parsers::AWS::Elasticache::DescribeCacheClusters.new + ) + end + + end + + class Mock + def describe_cache_clusters + Fog::Mock.not_implemented + end + end + end + end +end diff --git a/lib/fog/aws/requests/elasticache/describe_cache_clusters.rb b/lib/fog/aws/requests/elasticache/describe_cache_clusters.rb index 4c61c6035..8e7968c8e 100644 --- a/lib/fog/aws/requests/elasticache/describe_cache_clusters.rb +++ b/lib/fog/aws/requests/elasticache/describe_cache_clusters.rb @@ -5,7 +5,7 @@ module Fog require 'fog/aws/parsers/elasticache/describe_cache_clusters' - # Returns a list of CacheCluster descriptions + # Returns a list of Cache Cluster descriptions # # === Parameters # * options <~Hash> (optional): diff --git a/tests/aws/requests/elasticache/cache_cluster_tests.rb b/tests/aws/requests/elasticache/cache_cluster_tests.rb index e84755210..5ac07b911 100644 --- a/tests/aws/requests/elasticache/cache_cluster_tests.rb +++ b/tests/aws/requests/elasticache/cache_cluster_tests.rb @@ -44,16 +44,24 @@ Shindo.tests('AWS::Elasticache | cache cluster requests', ['aws', 'elasticache'] #cluster = AWS[:elasticache].clusters.get(cluster_id) #cluster.wait_for {ready?} - # - #tests( - #'#delete_cache_security_group' - #).formats(AWS::Elasticache::Formats::SINGLE_CACHE_CLUSTER) do - # body = AWS[:elasticache].delete_cache_security_group(cluster_id).body - #cluster = body['CacheCluster'] - #returns(cluster_id) { cluster['CacheClusterId'] } - #returns('deleting') { cluster['CacheClusterStatus'] } - #body - #end + + tests( + '#delete_cache_security_group' + ).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do + body = AWS[:elasticache].delete_cache_cluster(cluster_id).body + # make sure this particular cluster is in the returned list + returns(true, "has #{cluster_id}") do + body['CacheClusters'].any? do |cluster| + cluster['CacheClusterId'] == cluster_id + end + end + # now check that it reports itself as 'deleting' + cluster = body['CacheClusters'].find do |cluster| + cluster['CacheClusterId'] == cluster_id + end + returns('deleting') { cluster['CacheClusterStatus'] } + cluster + end end tests('failure') do diff --git a/tests/aws/requests/elasticache/helper.rb b/tests/aws/requests/elasticache/helper.rb index 38b6c0d22..f9be7d75a 100644 --- a/tests/aws/requests/elasticache/helper.rb +++ b/tests/aws/requests/elasticache/helper.rb @@ -31,8 +31,7 @@ class AWS } CACHE_CLUSTER_RUNNING = CACHE_CLUSTER.merge( 'CacheClusterCreateTime' => DateTime, - 'PreferredAvailabilityZone' => String, - 'CacheNodes' => Array + 'PreferredAvailabilityZone' => String ) CACHE_CLUSTER_MODIFIED = CACHE_CLUSTER_RUNNING.merge( 'NotificationConfiguration' => Hash,