Sha256: d283dd7d7e818f4af818e2a9e95aef5bebe8772e8f2586a8a4288f6bbcccd635

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

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

# Test class for Create Availability Set Request
class TestCreateAvailabilitySet < Minitest::Test
  def setup
    @service = Fog::Compute::AzureRM.new(credentials)
    client = @service.instance_variable_get(:@compute_mgmt_client)
    @availability_sets = client.availability_sets
    @promise = Concurrent::Promise.execute do
    end
  end

  def test_create_availability_set_success
    response = ApiStub::Requests::Compute::AvailabilitySet.create_availability_set_response
    @promise.stub :value!, response do
      @availability_sets.stub :create_or_update, @promise do
        assert_equal @service.create_availability_set('fog-test-rg', 'fog-test-as', 'west us'), Azure::ARM::Compute::Models::AvailabilitySet.serialize_object(response.body)
      end
    end
  end

  def test_create_availability_set_failure
    response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
    @promise.stub :value!, response do
      @availability_sets.stub :create_or_update, @promise do
        assert_raises(RuntimeError) { @service.create_availability_set('fog-test-rg', 'fog-test-as', 'west us') }
      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_create_availability_set.rb