Sha256: a7e86a2f4a258d3e3f4cd85c86d6de99a137883dc1c7744ac9b1d9c1379e247e

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

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

# Test class for Restart Virtual Machine Request
class TestRestartVirtualMachine < Minitest::Test
  def setup
    @service = Fog::Compute::AzureRM.new(credentials)
    client = @service.instance_variable_get(:@compute_mgmt_client)
    @virtual_machines = client.virtual_machines
    @promise = Concurrent::Promise.execute do
    end
  end

  def test_restart_virtual_machine_success
    @promise.stub :value!, true do
      @virtual_machines.stub :restart, @promise do
        assert @service.restart_virtual_machine('fog-test-rg', 'fog-test-server')
      end
    end
  end

  def test_restart_virtual_machine_failure
    response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
    @promise.stub :value!, response do
      @virtual_machines.stub :restart, @promise do
        assert_raises(RuntimeError) { @service.restart_virtual_machine('fog-test-rg', 'fog-test-server') }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.4 test/requests/compute/test_restart_virtual_machine.rb