Sha256: 020a8fefe7eae54debff57b1e10da34d9b23cba87b39a7445957abe9d8147912

Contents?: true

Size: 1.71 KB

Versions: 14

Compression:

Stored size: 1.71 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(MsRestAzure::AzureOperationError) { @service.check_vm_exists('fog-test-rg', 'fog-test-server', false) }
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
fog-azure-rm-0.6.0 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.5.3 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.5.2 test/requests/compute/test_check_vm_exists.rb
far-gem-0.5.6 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.5.1 test/requests/compute/test_check_vm_exists.rb
far-gem-0.5.5 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.5.0 test/requests/compute/test_check_vm_exists.rb
far-gem-0.5.4 test/requests/compute/test_check_vm_exists.rb
far-gem-0.5.3 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.4.9 test/requests/compute/test_check_vm_exists.rb
far-gem-0.5.2 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.4.8 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.4.7 test/requests/compute/test_check_vm_exists.rb
fog-azure-rm-0.4.6 test/requests/compute/test_check_vm_exists.rb