Sha256: a0bca2cef266612a9a0fa26e6c2276a7d816ac9df88f7e50e9a5b9b5085f9117

Contents?: true

Size: 1.76 KB

Versions: 33

Compression:

Stored size: 1.76 KB

Contents

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

# Test class for Get Records From Record Set Request
class TestGetRecordsFromRecordSet < 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_get_records_from_record_set_of_a_type_success
    mocked_response = ApiStub::Requests::DNS::RecordSet.record_set_response_for_a_type_response(@dns_client)
    @record_sets.stub :get, mocked_response do
      assert_equal @service.get_records_from_record_set('fog-test-rg', 'fog-test-record-set', 'fog-test-zone', 'A'), mocked_response.arecords
    end
  end

  def test_get_records_from_record_set_of_cname_type_success
    mocked_response = ApiStub::Requests::DNS::RecordSet.record_set_response_for_cname_type(@dns_client)
    @record_sets.stub :get, mocked_response do
      assert_equal @service.get_records_from_record_set('fog-test-rg', 'fog-test-record-set', 'fog-test-zone', 'CNAME'), mocked_response.cname_record
    end
  end

  def test_get_records_from_record_set_failure
    response = ApiStub::Requests::DNS::RecordSet.list_record_sets_response(@dns_client)
    @record_sets.stub :get, response do
      assert_raises ArgumentError do
        @service.get_records_from_record_set('fog-test-rg', 'fog-test-record-set', 'fog-test-zone')
      end
    end
  end

  def test_get_records_from_record_set_exception
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
    @record_sets.stub :get, response do
      assert_raises RuntimeError do
        @service.get_records_from_record_set('fog-test-rg', 'fog-test-record-set', 'fog-test-zone', '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_get_records_from_record_set.rb
fog-azure-rm-0.3.1 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-downgraded-0.3.0 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.3.0 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.2.7 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.2.6 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.2.5 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.2.4 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.2.3 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.2.2 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.2.1 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.2.0 test/requests/dns/test_get_records_from_record_set.rb
fog-azure-rm-0.1.2 test/requests/dns/test_get_records_from_record_set.rb