Sha256: c0943c0de7bb7161668a7d03baca71cff01876a310e2f961feeb3baabd48b038

Contents?: true

Size: 1.46 KB

Versions: 18

Compression:

Stored size: 1.46 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 RuntimeError do
          @service.detach_data_disk_from_vm('fog-test-rg', 'fog-test-vm', 'mydatadisk1', false)
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
fog-azure-rm-0.4.5 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-temp-0.0.5 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.4.4 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.4.3 test/requests/compute/test_detach_data_disk_from_vm.rb
far-gem-0.5.1 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.4.2 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.4.1 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.4.0 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.3.9 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.3.8 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.3.7 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.3.6 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.3.5 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.3.4 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-temp-0.0.4 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-temp-0.0.3 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-0.3.3 test/requests/compute/test_detach_data_disk_from_vm.rb
fog-azure-rm-temp-0.0.2 test/requests/compute/test_detach_data_disk_from_vm.rb