Sha256: 56135a27399df326af8a2d60dfc7f153bac6a8f2bae74f6b70f95c536a586f90

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

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

# Test class for Check for Public Ip Request
class TestCheckForPublicIp < Minitest::Test
  def setup
    @service = Fog::Network::AzureRM.new(credentials)
    network_client = @service.instance_variable_get(:@network_client)
    @public_ips = network_client.public_ipaddresses
  end

  def test_check_for_public_ip_success
    @public_ips.stub :get, true do
      assert @service.check_for_public_ip('fog-test-rg', 'fog-test-public-ip')
    end
  end

  def test_check_for_public_ip_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
    @public_ips.stub :get, response do
      assert !@service.check_for_public_ip('fog-test-rg', 'fog-test-public-ip')
    end
  end

  def test_check_for_public_ip_exception
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
    @public_ips.stub :get, response do
      assert_raises(RuntimeError) { @service.check_for_public_ip('fog-test-rg', 'fog-test-public-ip') }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.1.2 test/requests/network/test_check_for_public_ip.rb