Sha256: a23691a8ec50a3af141aa8b946f30bb4218456e81d446d6979ab126d6f80702e

Contents?: true

Size: 1.84 KB

Versions: 11

Compression:

Stored size: 1.84 KB

Contents

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

11 entries across 11 versions & 2 rubygems

Version Path
fog-1.36.0 tests/vsphere/requests/compute/get_network_tests.rb
fog-1.35.0 tests/vsphere/requests/compute/get_network_tests.rb
fog-2.0.0.pre.0 tests/vsphere/requests/compute/get_network_tests.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/tests/vsphere/requests/compute/get_network_tests.rb
fog-1.34.0 tests/vsphere/requests/compute/get_network_tests.rb
fog-1.33.0 tests/vsphere/requests/compute/get_network_tests.rb
fog-1.32.0 tests/vsphere/requests/compute/get_network_tests.rb
fog-1.31.0 tests/vsphere/requests/compute/get_network_tests.rb
fog-1.30.0 tests/vsphere/requests/compute/get_network_tests.rb
fog-1.29.0 tests/vsphere/requests/compute/get_network_tests.rb
fog-1.28.0 tests/vsphere/requests/compute/get_network_tests.rb