mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
added better acceptance criteria to server/image metadata tests; added metadata to ignored_attributes to address bug
This commit is contained in:
parent
90c310a1c4
commit
49d1c385a6
5 changed files with 13 additions and 5 deletions
|
@ -104,7 +104,7 @@ module Fog
|
|||
end
|
||||
|
||||
def ignore_attributes(*args)
|
||||
@ignored_attributes = args
|
||||
@ignored_attributes = args.collect {|attr| attr.to_s }
|
||||
end
|
||||
|
||||
def ignored_attributes
|
||||
|
|
|
@ -23,6 +23,8 @@ module Fog
|
|||
attribute :minRam
|
||||
attribute :disk_config, :aliases => 'OS-DCF:diskConfig'
|
||||
attribute :links
|
||||
|
||||
ignore_attributes :metadata
|
||||
|
||||
def initialize(attributes={})
|
||||
@connection = attributes[:connection]
|
||||
|
|
|
@ -30,12 +30,14 @@ module Fog
|
|||
end
|
||||
|
||||
def [](key)
|
||||
return super(key) if key.is_a?(Integer)
|
||||
return nil unless key
|
||||
datum = self.find {|datum| datum.key == key || datum.key == key.to_sym }
|
||||
datum ? datum.value : nil
|
||||
end
|
||||
|
||||
def []=(key, value)
|
||||
return super(key,value) if key.is_a?(Integer)
|
||||
return nil unless key
|
||||
datum = self.find {|datum| datum.key == key || datum.key == key.to_sym }
|
||||
if datum
|
||||
|
|
|
@ -42,6 +42,8 @@ module Fog
|
|||
attribute :flavor_id, :aliases => 'flavor', :squash => 'id'
|
||||
attribute :image_id, :aliases => 'image', :squash => 'id'
|
||||
|
||||
ignore_attributes :metadata
|
||||
|
||||
attr_reader :password
|
||||
def initialize(attributes={})
|
||||
@connection = attributes[:connection]
|
||||
|
|
|
@ -9,7 +9,6 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata', ['rackspace']) do
|
|||
begin
|
||||
@server = service.servers.create(:name => "fog_server_#{test_time}", :flavor_id => 2, :image_id => "3afe97b2-26dc-49c5-a2cc-a2fc8d80c001")
|
||||
@server.wait_for(timeout=1500) { ready? }
|
||||
@server = service.servers.get "2ee0e1b5-3350-40ae-873a-fff4941cc400"
|
||||
|
||||
tests('server') do
|
||||
collection_tests(@server.metadata, {:key => 'my_key', :value => 'my_value'}) do
|
||||
|
@ -23,12 +22,15 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata', ['rackspace']) do
|
|||
@image.wait_for(timeout = 1500) { ready? }
|
||||
tests("#all").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@image.metadata.all
|
||||
metadata = @image.metadata.all
|
||||
my_metadata = metadata.select {|datum| datum.key == 'my_key'}
|
||||
returns(1) { my_metadata.size }
|
||||
returns('my_value') {my_metadata[0].value }
|
||||
end
|
||||
|
||||
tests("#get('my_key')").succeeds do
|
||||
tests("#get('my_key')").returns('my_value') do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@image.metadata.get('my_key')
|
||||
@image.metadata.get('my_key').value
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue