Sha256: dd95f32992c56b099212c7572a7bf264c8122b46de4d44ab05bd219487ad9d0b

Contents?: true

Size: 1.9 KB

Versions: 3

Compression:

Stored size: 1.9 KB

Contents

require File.expand_path '../../test_helper', __dir__

# Test class for VirtualNetwork Collection
class TestVirtualNetworks < Minitest::Test
  def setup
    @service = Fog::Network::AzureRM.new(credentials)
    @virtual_networks = Fog::Network::AzureRM::VirtualNetworks.new(resource_group: 'fog-test-rg', service: @service)
    @network_client = @service.instance_variable_get(:@network_client)
  end

  def test_collection_methods
    methods = [
      :all,
      :get,
      :check_if_exists
    ]
    methods.each do |method|
      assert @virtual_networks.respond_to? method
    end
  end

  def test_collection_attributes
    assert @virtual_networks.respond_to? :resource_group
  end

  def test_all_method_response
    response = [ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response(@network_client)]
    @service.stub :list_virtual_networks, response do
      assert_instance_of Fog::Network::AzureRM::VirtualNetworks, @virtual_networks.all
      assert @virtual_networks.all.size >= 1
      @virtual_networks.all.each do |nic|
        assert_instance_of Fog::Network::AzureRM::VirtualNetwork, nic
      end
    end
  end

  def test_get_method_response
    response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response(@network_client)
    @service.stub :get_virtual_network, response do
      assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_networks.get('fog-rg', 'fog-test-virtual-network')
    end
  end

  def test_check_if_exists_method_success
    @service.stub :check_for_virtual_network, true do
      assert @virtual_networks.check_if_exists('fog-test-rg', 'fog-test-virtual-network')
    end
  end

  def test_check_if_exists_method_failure
    @service.stub :check_for_virtual_network, false do
      assert !@virtual_networks.check_if_exists('fog-test-rg', 'fog-test-virtual-network')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.8 test/models/network/test_virtual_networks.rb
fog-azure-rm-0.0.6 test/models/network/test_virtual_networks.rb
fog-azure-rm-0.0.5 test/models/network/test_virtual_networks.rb