Sha256: 6e04752f9f33942f761871ac04dadf170b430f09dc527ba6d6038f69328f202e

Contents?: true

Size: 1021 Bytes

Versions: 116

Compression:

Stored size: 1021 Bytes

Contents

require './test/test_helper'
require 'logger'

class CursorMessageTest < Test::Unit::TestCase

  include Mongo

  @@connection = standard_connection
  @@db   = @@connection.db(MONGO_TEST_DB)
  @@coll = @@db.collection('test')
  @@version = @@connection.server_version

  def setup
    @@coll.remove
    @@coll.insert('a' => 1)     # collection not created until it's used
    @@coll_full_name = "#{MONGO_TEST_DB}.test"
  end

  def test_valid_batch_sizes
    assert_raise ArgumentError do
      @@coll.find({}, :batch_size => 1, :limit => 5)
    end

    assert_raise ArgumentError do
      @@coll.find({}, :batch_size => -1, :limit => 5)
    end

    assert @@coll.find({}, :batch_size => 0, :limit => 5)
  end

  def test_batch_size
    @@coll.remove
    200.times do |n|
      @@coll.insert({:a => n})
    end

    list = @@coll.find({}, :batch_size => 2, :limit => 6).to_a
    assert_equal 6, list.length

    list = @@coll.find({}, :batch_size => 100, :limit => 101).to_a
    assert_equal 101, list.length
  end
end

Version data entries

116 entries across 70 versions & 6 rubygems

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