1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/aws/requests/elasticache/cache_cluster_tests.rb
2011-09-27 18:25:14 -05:00

73 lines
2.2 KiB
Ruby

Shindo.tests('AWS::Elasticache | cache cluster requests', ['aws', 'elasticache']) do
tests('success') do
pending if Fog.mocking?
cluster_id = 'fog-test-cluster'
tests(
'#create_cache_cluster'
).formats(AWS::Elasticache::Formats::SINGLE_CACHE_CLUSTER) do
body = AWS[:elasticache].create_cache_cluster(
:cluster_id => cluster_id
).body
cluster = body['CacheCluster']
returns(cluster_id) { cluster['CacheClusterId'] }
returns('creating') { cluster['CacheClusterStatus'] }
body
end
tests(
'#describe_cache_clusters without options'
).formats(AWS::Elasticache::Formats::DESCRIBE_CACHE_CLUSTERS) do
body = AWS[:elasticache].describe_cache_clusters.body
returns(true, "has #{cluster_id}") do
body['CacheClusters'].any? do |cluster|
cluster['CacheClusterId'] == cluster_id
end
end
body
end
tests(
'#describe_cache_clusters with cluster ID'
).formats(AWS::Elasticache::Formats::DESCRIBE_CACHE_CLUSTERS) do
body = AWS[:elasticache].describe_cache_clusters(
'CacheClusterId' => cluster_id
).body
returns(1, "size of 1") { body['CacheClusters'].size }
returns(cluster_id, "has #{cluster_id}") do
body['CacheClusters'].first['CacheClusterId']
end
body
end
#cluster = AWS[:elasticache].clusters.get(cluster_id)
#cluster.wait_for {ready?}
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
# TODO:
# Create a duplicate cluster ID
# List a missing cache cluster
# Delete a missing cache cluster
end
end