Sha256: e865478e4ab850807d70719ce762ec96594ecaa1cb275bd1619814fd46035154

Contents?: true

Size: 1.69 KB

Versions: 7

Compression:

Stored size: 1.69 KB

Contents

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

# Test class for Check Virtual Machine Exists Request
class TestCheckVirtualMachineExists < Minitest::Test
  def setup
    @service = Fog::Compute::AzureRM.new(credentials)
    @compute_client = @service.instance_variable_get(:@compute_mgmt_client)
    @virtual_machines = @compute_client.virtual_machines
  end

  def test_check_vm_exists_success
    response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response(@compute_client)
    @virtual_machines.stub :get, response do
      assert @service.check_vm_exists('fog-test-rg', 'fog-test-server', false)
    end
  end

  def test_check_vm_exists_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
    @virtual_machines.stub :get, response do
      assert !@service.check_vm_exists('fog-test-rg', 'fog-test-server', false)
    end
  end

  def test_check_vm_resource_group_exists_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
    @virtual_machines.stub :get, response do
      assert !@service.check_vm_exists('fog-test-rg', 'fog-test-server', false)
    end
  end

  def test_check_vm_exists_exception
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
    @virtual_machines.stub :get, response do
      assert_raises(RuntimeError) { @service.check_vm_exists('fog-test-rg', 'fog-test-server', false) }
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
fog-azure-rm-0.4.5 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-temp-0.0.5 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.4.4 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.4.3 test/requests/compute/test_check_vm_exists.rb
far-gem-0.5.1 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.4.2 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.4.1 test/requests/compute/test_check_vm_exists.rb