Sha256: 42b05f597a59ada43192b93ae4594170b3555fadf5e01649433ce06d5df94643

Contents?: true

Size: 1.48 KB

Versions: 14

Compression:

Stored size: 1.48 KB

Contents

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

# Test class for Detach Data Disk from VM Request
class TestDetachDataDiskFromVM < 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_detach_data_disk_from_vm_success
    get_vm_response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response(@compute_client)
    update_vm_response = ApiStub::Requests::Compute::VirtualMachine.detach_data_disk_from_vm_response(@compute_client)
    @virtual_machines.stub :get, get_vm_response do
      @virtual_machines.stub :create_or_update, update_vm_response do
        assert_equal @service.detach_data_disk_from_vm('fog-test-rg', 'fog-test-vm', 'mydatadisk1', false), update_vm_response
      end
    end
  end

  def test_detach_data_disk_from_vm_failure
    get_vm_response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response(@compute_client)
    update_vm_response = proc { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
    @virtual_machines.stub :get, get_vm_response do
      @virtual_machines.stub :create_or_update, update_vm_response do
        assert_raises MsRestAzure::AzureOperationError do
          @service.detach_data_disk_from_vm('fog-test-rg', 'fog-test-vm', 'mydatadisk1', false)
        end
      end
    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_detach_data_disk_from_vm.rb
fog-azure-rm-0.5.3 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.5.2 test/requests/compute/test_detach_data_disk_from_vm.rb
far-gem-0.5.6 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.5.1 test/requests/compute/test_detach_data_disk_from_vm.rb
far-gem-0.5.5 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.5.0 test/requests/compute/test_detach_data_disk_from_vm.rb
far-gem-0.5.4 test/requests/compute/test_detach_data_disk_from_vm.rb
far-gem-0.5.3 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.4.9 test/requests/compute/test_detach_data_disk_from_vm.rb
far-gem-0.5.2 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.4.8 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.4.7 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.4.6 test/requests/compute/test_detach_data_disk_from_vm.rb