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

find_by_query support for vdcs collection

This commit is contained in:
Mike Pountney 2014-06-18 00:52:30 +01:00
parent 6537947a40
commit a440f3d6b9
2 changed files with 21 additions and 0 deletions

View file

@ -5,10 +5,17 @@ module Fog
module Compute module Compute
class VcloudDirector class VcloudDirector
class Vdcs < Collection class Vdcs < Collection
include Fog::VcloudDirector::Query
model Fog::Compute::VcloudDirector::Vdc model Fog::Compute::VcloudDirector::Vdc
attribute :organization attribute :organization
def query_type
"orgVdc"
end
private private
def get_by_id(item_id) def get_by_id(item_id)

View file

@ -37,4 +37,18 @@ Shindo.tests("Compute::VcloudDirector | vdcs", ['vclouddirector', 'all']) do
tests("#get_by_name").returns(vdc.name) { vdcs.get_by_name(vdc.name).name } tests("#get_by_name").returns(vdc.name) { vdcs.get_by_name(vdc.name).name }
tests("#get").returns(vdc.id) { vdcs.get(vdc.id).id } tests("#get").returns(vdc.id) { vdcs.get(vdc.id).id }
end end
pending if Fog.mocking?
# We should also be able to find this same vdc via Query API
tests("Compute::VcloudDirector | vdcs", ['find_by_query']) do
tests('we can retrieve :name without lazy loading').returns(vdc.name) do
query_vdc = vdcs.find_by_query(:filter => "name==#{vdc.name}").first
query_vdc.attributes[:name]
end
tests('by name').returns(vdc.name) do
query_vdc = vdcs.find_by_query(:filter => "name==#{vdc.name}").first
query_vdc.name
end
end
end end