1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/vcloud_director/requests/compute/edge_gateway_tests.rb

38 lines
1.3 KiB
Ruby
Raw Normal View History

2013-10-07 08:13:22 -04:00
Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector']) do
@service = Fog::Compute::VcloudDirector.new
@org = VcloudDirector::Compute::Helper.current_org(@service)
2013-10-07 08:13:22 -04:00
tests('Get first vDC') do
2013-10-07 08:13:22 -04:00
link = @org[:Link].detect do |l|
l[:type] == 'application/vnd.vmware.vcloud.vdc+xml'
end
@vdc_id = link[:href].split('/').last
end
tests('#get_edge_gateways').data_matches_schema(VcloudDirector::Compute::Schema::QUERY_RESULT_RECORDS_TYPE) do
@edge_gateways = @service.get_edge_gateways(@vdc_id).body
# ensure that EdgeGatewayRecord is a list
if @edge_gateways[:EdgeGatewayRecord].is_a?(Hash)
@edge_gateways[:EdgeGatewayRecord] = [@edge_gateways[:EdgeGatewayRecord]]
end
@edge_gateways[:EdgeGatewayRecord].each do |result|
tests("each EdgeGatewayRecord should follow schema").
data_matches_schema(VcloudDirector::Compute::Schema::QUERY_RESULT_EDGE_GATEWAY_RECORD_TYPE) { result }
2013-10-07 08:13:22 -04:00
end
@edge_gateways
end
tests('#get_edge_gateway').data_matches_schema(VcloudDirector::Compute::Schema::GATEWAY_TYPE) do
@service.get_edge_gateway(@edge_gateways[:EdgeGatewayRecord].first[:href].split('/').last).body
end
tests('Retrieve non-existent edge gateway').raises(Excon::Errors::Forbidden) do
@service.get_edge_gateway('00000000-0000-0000-0000-000000000000')
end
end