Sha256: ea771be1621d6ff4a7d67ee26f29a3a6f86a6612716bb975d6bac61cdc4349f9

Contents?: true

Size: 1.83 KB

Versions: 33

Compression:

Stored size: 1.83 KB

Contents

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

# Test class for Create Record Set Request
class TestCreateRecordSet < Minitest::Test
  def setup
    @service = Fog::DNS::AzureRM.new(credentials)
    @dns_client = @service.instance_variable_get(:@dns_client)
    @record_sets = @dns_client.record_sets
  end

  def test_create_or_update_record_set_a_type
    mocked_response = ApiStub::Requests::DNS::RecordSet.record_set_response_for_a_type_response(@dns_client)
    record_set_params = { records: %w(1.2.3.4 1.2.3.3) }
    @record_sets.stub :create_or_update, mocked_response do
      assert_equal @service.create_or_update_record_set(record_set_params, 'A'), mocked_response
    end
  end

  def test_create_or_update_record_set_cname_type
    mocked_response = ApiStub::Requests::DNS::RecordSet.record_set_response_for_cname_type(@dns_client)
    record_set_params = { records: %w(1.2.3.4 1.2.3.3) }
    @record_sets.stub :create_or_update, mocked_response do
      assert_equal @service.create_or_update_record_set(record_set_params, 'CNAME'), mocked_response
    end
  end

  def test_create_or_update_record_set_failure
    response = ApiStub::Requests::DNS::RecordSet.list_record_sets_response(@dns_client)
    record_set_params = { records: %w(1.2.3.4 1.2.3.3) }
    @record_sets.stub :create_or_update, response do
      assert_raises ArgumentError do
        @service.create_or_update_record_set(record_set_params)
      end
    end
  end

  def test_create_or_update_record_set_exception
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
    record_set_params = { records: %w(1.2.3.4 1.2.3.3) }
    @record_sets.stub :create_or_update, response do
      assert_raises RuntimeError do
        @service.create_or_update_record_set(record_set_params, 'CNAME')
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
fog-azure-rm-downgraded-0.3.1 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.3.1 test/requests/dns/test_create_record_set.rb
fog-azure-rm-downgraded-0.3.0 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.3.0 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.2.7 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.2.6 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.2.5 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.2.4 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.2.3 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.2.2 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.2.1 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.2.0 test/requests/dns/test_create_record_set.rb
fog-azure-rm-0.1.2 test/requests/dns/test_create_record_set.rb