Sha256: 79d1e70d82e316b39fd6e58b50a469bf2695bfb13c20a6b99ea7c7a07e8d47ff

Contents?: true

Size: 1.12 KB

Versions: 132

Compression:

Stored size: 1.12 KB

Contents

require './test/test_helper'

# NOTE: these tests are run only if we can connect to a single MongoDB in slave mode.
class SlaveConnectionTest < Test::Unit::TestCase
  include Mongo

  def self.connect_to_slave
    @@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
    @@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
    conn = Connection.new(@@host, @@port, :slave_ok => true)
    response = conn['admin'].command(:ismaster => 1)
    Mongo::Support.ok?(response) && response['ismaster'] != 1
  end

  if self.connect_to_slave
    puts "Connected to slave; running slave tests."

    def test_connect_to_slave
      assert_raise Mongo::ConnectionFailure do
        @db = Connection.new(@@host, @@port, :slave_ok => false).db('ruby-mongo-demo')
      end
    end

    def test_slave_ok_sent_to_queries
      @con = Connection.new(@@host, @@port, :slave_ok => true)
      assert_equal true, @con.slave_ok?
    end
  else
    puts "Not connected to slave; skipping slave connection tests."

    def test_slave_ok_false_on_queries
      @conn = Connection.new(@@host, @@port)
      assert !@conn.slave_ok?
    end
  end
end

Version data entries

132 entries across 86 versions & 7 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb
classiccms-0.7.5 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.7.4 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.7.4 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb
classiccms-0.7.3 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.7.3 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb
classiccms-0.7.2 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb
classiccms-0.7.2 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.7.1 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.7.1 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb
classiccms-0.7.0 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.7.0 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb
classiccms-0.6.9 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.6.9 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb
classiccms-0.6.8 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.6.8 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb
classiccms-0.6.7 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.6.7 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb
classiccms-0.6.6 vendor/bundle/gems/mongo-1.6.1/test/auxillary/slave_connection_test.rb
classiccms-0.6.6 vendor/bundle/gems/mongo-1.6.2/test/auxillary/slave_connection_test.rb