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

[vcloud_director] Fix medias#create - issue #2440

This commit is contained in:
Nick Osborn 2013-12-02 13:44:14 +00:00
parent a76414b40a
commit 8b8a961f2e
2 changed files with 19 additions and 6 deletions

View file

@ -23,7 +23,7 @@ module Fog
# Perhaps this would be better implemented as media#upload.
file = response.body[:Files][:File]
file = response.body[:Files][:File].first
file[:Link] = [file[:Link]] if file[:Link].is_a?(Hash)
link = file[:Link].detect {|l| l[:rel] == 'upload:default'}

View file

@ -4,8 +4,17 @@ Shindo.tests('Compute::VcloudDirector | media', ['vclouddirector']) do
pending if Fog.mocking?
medias = vdc.medias
pending if medias.all.empty?
media = medias.first
media_name = VcloudDirector::Compute::Helper.test_name
tests('Compute::VcloudDirector | media', ['create']) do
tests('#create').returns(Fog::Compute::VcloudDirector::Media) do
File.open(VcloudDirector::Compute::Helper.fixture('test.iso'), 'rb') do |iso|
medias.create(media_name, iso).class
end
end
end
media = medias.get_by_name(media_name)
tests('Compute::VcloudDirector | media') do
tests('#href').returns(String) { media.href.class }
@ -21,9 +30,9 @@ Shindo.tests('Compute::VcloudDirector | media', ['vclouddirector']) do
end
tests('Compute::VcloudDirector | media', ['load on demand']) do
tests("#description is not loaded yet").returns(NonLoaded) { media.attributes[:description] }
tests("#description is loaded on demand").returns(String) { media.description.class }
tests("#description is now loaded").returns(true) { media.attributes[:description] != NonLoaded }
tests('#description is not loaded yet').returns(NonLoaded) { media.attributes[:description] }
tests('#description is loaded on demand').returns(String) { media.description.class }
tests('#description is now loaded').returns(true) { media.attributes[:description] != NonLoaded }
end
tests('Compute::VcloudDirector | media', ['lazy load attrs']) do
@ -42,4 +51,8 @@ Shindo.tests('Compute::VcloudDirector | media', ['vclouddirector']) do
tests('#get_by_name').returns(media.name) { medias.get_by_name(media.name).name }
tests('#get').returns(media.id) { medias.get(media.id).id }
end
tests('Compute::VcloudDirector | media', ['destroy']) do
tests('#destroy').returns(true) { media.destroy }
end
end