Sha256: 33962ed0cdbd591e892f8385b77dc7def3e3ea6b50f8b228f434c8d1949983e3

Contents?: true

Size: 1.91 KB

Versions: 6

Compression:

Stored size: 1.91 KB

Contents

require 'lite_spec_helper'

require 'runners/connection_string'

describe 'DNS Seedlist Discovery' do
  require_external_connectivity

  include Mongo::ConnectionString

  DNS_SEEDLIST_DISCOVERY_TESTS.each do |test_path|

    spec = YAML.load(File.read(test_path))

    test = Mongo::ConnectionString::Test.new(spec)

    context(File.basename(test_path)) do

      context 'when the uri is invalid', if: test.raise_error? do

        let(:valid_errors) do
          [
            Mongo::Error::InvalidTXTRecord,
            Mongo::Error::NoSRVRecords,
            Mongo::Error::InvalidURI,
            Mongo::Error::MismatchedDomain,
          ]
        end

        let(:error) do
          e = nil
          begin; test.uri; rescue => ex; e = ex; end
          e
        end

        it 'raises an error' do
          expect(valid_errors).to include(error.class)
        end
      end

      context 'when the uri is valid', unless: test.raise_error? do

        it 'does not raise an exception' do
          expect(test.uri).to be_a(Mongo::URI::SRVProtocol)
        end

        if test.seeds
          # DNS seed list tests specify both seeds and hosts.
          # To get the hosts, the client must do SDAM (as required in the
          # spec tests' description), but this isn't testing DNS seed list -
          # it is testing SDAM. Plus, all of the hosts are always the same.
          # If seed list is given in the expectations, just test the seed
          # list and not the expanded hosts.
          it 'creates a client with the correct seeds' do
            expect(test.client).to have_hosts(test, test.seeds)
          end
        else
          it 'creates a client with the correct hosts' do
            expect(test.client).to have_hosts(test, test.hosts)
          end
        end

        it 'creates a client with the correct options' do
          expect(test.client).to match_options(test)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongo-2.13.3 spec/spec_tests/dns_seedlist_discovery_spec.rb
mongo-2.13.2 spec/spec_tests/dns_seedlist_discovery_spec.rb
mongo-2.13.1 spec/spec_tests/dns_seedlist_discovery_spec.rb
mongo-2.13.0 spec/spec_tests/dns_seedlist_discovery_spec.rb
mongo-2.13.0.rc1 spec/spec_tests/dns_seedlist_discovery_spec.rb
mongo-2.13.0.beta1 spec/spec_tests/dns_seedlist_discovery_spec.rb