Sha256: 256349dbbf64bfd57aea2ff1549610cd0f906a1fcce0dd60df800333c7cb7bea

Contents?: true

Size: 1.55 KB

Versions: 10

Compression:

Stored size: 1.55 KB

Contents

# Copyright (C) 2009-2013 MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'test_helper'
require 'logger'

class CursorMessageTest < Test::Unit::TestCase

  include Mongo

  def setup
    @connection = standard_connection
    @db         = @connection.db(TEST_DB)
    @coll       = @db.collection('test')
    @version    = @connection.server_version
    @coll.remove
    @coll.insert('a' => 1)     # collection not created until it's used
    @coll_full_name = "#{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

10 entries across 10 versions & 1 rubygems

Version Path
mongo-1.12.5 test/functional/cursor_message_test.rb
mongo-1.12.4 test/functional/cursor_message_test.rb
mongo-1.12.3 test/functional/cursor_message_test.rb
mongo-1.12.2 test/functional/cursor_message_test.rb
mongo-1.12.1 test/functional/cursor_message_test.rb
mongo-1.12.0 test/functional/cursor_message_test.rb
mongo-1.12.0.rc2 test/functional/cursor_message_test.rb
mongo-1.12.0.rc1 test/functional/cursor_message_test.rb
mongo-1.12.0.rc0 test/functional/cursor_message_test.rb
mongo-1.11.1 test/functional/cursor_message_test.rb