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

[compute|aws] enable tests for mocked tags.

This commit is contained in:
Dylan Egan 2011-09-06 09:36:12 -07:00
parent 2e046dde1e
commit cea6fd3edf
2 changed files with 6 additions and 18 deletions

View file

@ -39,10 +39,10 @@ module Fog
end
end
class Mock
def delete_tags(resources, tags)
tagged = resources.map do |resource_id|
tagged = Array(resources).map do |resource_id|
type = case resource_id
when /^ami\-[a-z0-9]{8}$/i
'image'
@ -59,11 +59,11 @@ module Fog
raise(Fog::Service::NotFound.new("The #{type} ID '#{resource_id}' does not exist"))
end
end
tags.each do |key, value|
self.data[:tags][key][value] = self.data[:tags][key][value] - tagged
end
tagged.each do |resource|
object = self.data[:"#{resource['resourceType']}s"][resource['resourceId']]
tags.each do |key, value|
@ -71,7 +71,7 @@ module Fog
tagset.delete(key) if tagset.has_key?(key) && (value.nil? || tagset[key] == value)
end
end
response = Excon::Response.new
response.status = true
response.body = {
@ -81,7 +81,7 @@ module Fog
response
end
end
end
end
end

View file

@ -1,5 +1,4 @@
Shindo.tests('Fog::Compute[:aws] | tag requests', ['aws']) do
@tags_format = {
'tagSet' => [{
'key' => String,
@ -14,30 +13,20 @@ Shindo.tests('Fog::Compute[:aws] | tag requests', ['aws']) do
@volume.wait_for { ready? }
tests('success') do
tests("#create_tags('#{@volume.identity}', 'foo' => 'bar')").formats(AWS::Compute::Formats::BASIC) do
Fog::Compute[:aws].create_tags(@volume.identity, 'foo' => 'bar').body
end
tests('#describe_tags').formats(@tags_format) do
pending if Fog.mocking?
Fog::Compute[:aws].describe_tags.body
end
tests("#delete_tags('#{@volume.identity}', 'foo' => 'bar')").formats(AWS::Compute::Formats::BASIC) do
pending if Fog.mocking?
Fog::Compute[:aws].delete_tags(@volume.identity, 'foo' => 'bar').body
end
tests("#delete_tags('vol-00000000', 'baz' => 'qux')").succeeds do
pending if Fog.mocking?
Fog::Compute[:aws].delete_tags('vol-00000000', 'baz' => 'qux')
end
end
tests('failure') do
tests("#create_tags('vol-00000000', 'baz' => 'qux')").raises(Fog::Service::NotFound) do
Fog::Compute[:aws].create_tags('vol-00000000', 'baz' => 'qux')
end
@ -45,5 +34,4 @@ Shindo.tests('Fog::Compute[:aws] | tag requests', ['aws']) do
end
@volume.destroy
end