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

fixes for formats with nullables

This commit is contained in:
geemus 2011-01-04 15:17:05 -08:00
parent 5322683b6e
commit c732cf1146
2 changed files with 10 additions and 13 deletions

View file

@ -1,24 +1,22 @@
Shindo.tests('Rackspace::Compute | image requests', ['rackspace']) do
@images_format = {
@image_format = {
'created' => Fog::Nullable::String,
'id' => Integer,
'name' => String,
'progress' => Fog::Nullable::Integer,
'serverId' => Fog::Nullable::Integer,
'status' => String,
'updated' => String,
'updated' => String
}
@image_format = @images_format.merge({
'created' => String,
'progress' => Integer,
})
tests('success') do
@server = Rackspace[:compute].servers.create(:flavor_id => 1, :image_id => 19)
@server.wait_for { ready? }
@image_id = nil
tests("#create_image(#{@server.id})").formats(@images_format.merge('serverId' => Integer)) do
tests("#create_image(#{@server.id})").formats(@image_format) do
data = Rackspace[:compute].create_image(@server.id).body['image']
@image_id = data['id']
data
@ -37,7 +35,7 @@ Shindo.tests('Rackspace::Compute | image requests', ['rackspace']) do
Rackspace[:compute].list_images.body
end
tests('#list_images_detail').formats({'images' => [@images_format]}) do
tests('#list_images_detail').formats({'images' => [@image_format]}) do
Rackspace[:compute].list_images_detail.body
end

View file

@ -4,11 +4,13 @@
module Fog
module Boolean; end
module Nullable
module Integer; end
module String; end
end
end
[FalseClass, TrueClass].each {|klass| klass.send(:include, Fog::Boolean)}
[NilClass, String].each {|klass| klass.send(:include, Fog::String)}
[NilClass, String].each {|klass| klass.send(:include, Fog::Nullable::String)}
[Integer, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Integer)}
module Shindo
class Tests
@ -30,7 +32,6 @@ module Shindo
format = {:element => format}
end
for key, value in format
valid &&= data.has_key?(key)
datum = data.delete(key)
format.delete(key)
case value
@ -41,8 +42,6 @@ module Shindo
type = value.first
if type.is_a?(Hash)
valid &&= formats_kernel({:element => element}, {:element => type}, false)
elsif type.nil?
p "#{key} => #{value}"
else
valid &&= element.is_a?(type)
end