Sha256: 1373e908856acc09d54b86f578eb21dd8fe950212e60e80dd44ab0cfe4001348
Contents?: true
Size: 1.86 KB
Versions: 44
Compression:
Stored size: 1.86 KB
Contents
require 'ostruct' Shindo.tests('Fog::Compute[:vsphere] | get_network request', ['vsphere']) do compute = Fog::Compute[:vsphere] class DistributedVirtualPortgroup attr_accessor :name, :dvs_name def initialize attrs @name = attrs.fetch(:name) @dvs_name = attrs.fetch(:dvs_name) end def config OpenStruct.new( :distributedVirtualSwitch => OpenStruct.new(:name => dvs_name)) end end fake_networks = [OpenStruct.new(:name => 'non-dvs'), DistributedVirtualPortgroup.new( :name => 'web1', :dvs_name => 'dvs5'), DistributedVirtualPortgroup.new( :name => 'web1', :dvs_name => 'dvs11'), DistributedVirtualPortgroup.new( :name => 'other', :dvs_name => 'other'), ] tests('#choose_finder should') do test('choose the network based on network name and dvs name'){ finder = compute.send(:choose_finder, 'web1', 'dvs11') found_network = fake_networks.find{ |n| finder.call(n) } found_network.name == 'web1' && found_network.dvs_name == 'dvs11' } test('choose the network based on network name and any dvs'){ finder = compute.send(:choose_finder, 'web1', :dvs) found_network = fake_networks.find{ |n| finder.call(n) } found_network.name == 'web1' && found_network.dvs_name == 'dvs5' } test('choose the network based on network name only'){ finder = compute.send(:choose_finder, 'other', nil) found_network = fake_networks.find{ |n| finder.call(n) } found_network.name == 'other' && found_network.dvs_name == 'other' } test('choose the network based on network name only for non-dvs'){ finder = compute.send(:choose_finder, 'non-dvs', nil) found_network = fake_networks.find{ |n| finder.call(n) } found_network.name == 'non-dvs' && found_network.class.name.to_s == 'OpenStruct' } end end
Version data entries
44 entries across 44 versions & 1 rubygems