Sha256: ff1baff76df916c8049a96c8de1ddaac7c2eb3543805f7c5d9123a13f38ebe96

Contents?: true

Size: 1.01 KB

Versions: 17

Compression:

Stored size: 1.01 KB

Contents

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'mongo'
require 'test/unit'
require 'test/test_helper'

# NOTE: This test requires bouncing the server
class AutoreconnectTest < Test::Unit::TestCase
  include Mongo

  def setup
    @conn = Mongo::Connection.new
    @db = @conn.db('mongo-ruby-test')
    @db.drop_collection("test-connect")
    @coll = @db.collection("test-connect")
  end

  def test_query
    @coll.save({:a => 20})
    @coll.save({:a => 30})
    @coll.save({:a => 40})
    results = []
    @coll.find.each {|r| results << r}
    [20, 30, 40].each do |a|
      assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
    end

    puts "Please disconnect and then reconnect the current master."
    gets

    begin
      @coll.find.to_a
      rescue Mongo::ConnectionFailure
    end

    results = []
      @coll.find.each {|r| results << r}
      [20, 30, 40].each do |a|
        assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
      end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
mongo-1.0.8 test/auxillary/autoreconnect_test.rb
mongo-1.0.7 test/auxillary/autoreconnect_test.rb
mongo-1.0.6 test/auxillary/autoreconnect_test.rb
mongo-1.0.5 test/auxillary/autoreconnect_test.rb
mongo-1.0.4 test/auxillary/autoreconnect_test.rb
mongo-1.0.3 test/auxillary/autoreconnect_test.rb
mongo-1.0.2 test/auxillary/autoreconnect_test.rb
mongo-1.0.1 test/auxillary/autoreconnect_test.rb
mongo-1.0 test/auxillary/autoreconnect_test.rb
mongo-0.20.1 test/auxillary/autoreconnect_test.rb
mongo-0.20 test/auxillary/autoreconnect_test.rb
mongo-0.19.3 test/auxillary/autoreconnect_test.rb
mongo-0.19.2 test/auxillary/autoreconnect_test.rb
mongo-0.19.1 test/auxillary/autoreconnect_test.rb
mongo-0.19 test/auxillary/autoreconnect_test.rb
kbaum-mongo-0.19 test/auxillary/autoreconnect_test.rb
kbaum-mongo-0.18.3.2 test/auxillary/autoreconnect_test.rb