Sha256: bee78e29a0b2760c3516456a341150052e5f41de3360ab2c73a3d9065511f495

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 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

6 entries across 6 versions & 1 rubygems

Version Path
fog-azure-rm-0.1.1 test/requests/network/test_check_for_public_ip.rb
fog-azure-rm-0.1.0 test/requests/network/test_check_for_public_ip.rb
fog-azure-rm-0.0.9 test/requests/network/test_check_for_public_ip.rb
fog-azure-rm-0.0.8 test/requests/network/test_check_for_public_ip.rb
fog-azure-rm-0.0.6 test/requests/network/test_check_for_public_ip.rb
fog-azure-rm-0.0.5 test/requests/network/test_check_for_public_ip.rb