Sha256: b521417cec1fba27d5551470d76821d9b9fa9f8ce93e34b40db62cb88fda5c3c

Contents?: true

Size: 1.29 KB

Versions: 20

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe 'Server' do
  let(:client) { authorized_client }

  let(:server) { client.cluster.next_primary }

  let(:collection) { client['collection'] }
  let(:view) { Mongo::Collection::View.new(collection) }

  describe 'operations when client/cluster are disconnected' do
    # Server versions lower than 3.4 use the legacy find result
    min_server_fcv '3.4'

    context 'normal server' do
      it 'can be used for reads' do
        result = view.send(:send_initial_query, server)
        expect(result).to be_a(Mongo::Operation::Find::Result)
      end
    end

    context 'known server in disconnected cluster' do
      before do
        client.close
        expect(server).not_to be_unknown
      end

      it 'can be used for reads' do
        result = view.send(:send_initial_query, server)
        expect(result).to be_a(Mongo::Operation::Find::Result)
      end
    end

    context 'unknown server in disconnected cluster' do
      before do
        client.close
        server.unknown!
        expect(server).to be_unknown
      end

      it 'can be used for reads' do
        result = view.send(:send_initial_query, server)
        # Driver falls back to the oldest MongoDB protocol
        expect(result).to be_a(Mongo::Operation::Find::Legacy::Result)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mongo-2.12.4 spec/integration/server_spec.rb
mongo-2.11.6 spec/integration/server_spec.rb
mongo-2.12.3 spec/integration/server_spec.rb
mongo-2.12.2 spec/integration/server_spec.rb
mongo-2.10.5 spec/integration/server_spec.rb
mongo-2.11.5 spec/integration/server_spec.rb
mongo-2.12.1 spec/integration/server_spec.rb
mongo-2.12.0.rc0 spec/integration/server_spec.rb
mongo-2.11.4 spec/integration/server_spec.rb
mongo-2.10.4 spec/integration/server_spec.rb
mongo-2.11.3 spec/integration/server_spec.rb
mongo-2.11.2 spec/integration/server_spec.rb
mongo-2.11.1 spec/integration/server_spec.rb
mongo-2.10.3 spec/integration/server_spec.rb
mongo-2.11.0 spec/integration/server_spec.rb
mongo-2.10.2 spec/integration/server_spec.rb
mongo-2.11.0.rc0 spec/integration/server_spec.rb
mongo-2.10.1 spec/integration/server_spec.rb
mongo-2.10.0 spec/integration/server_spec.rb
mongo-2.10.0.rc0 spec/integration/server_spec.rb