RUBY-267 Cursor#alive?
This commit is contained in:
parent
9a80fbaa66
commit
05dfef2f11
|
@ -307,6 +307,13 @@ module Mongo
|
|||
# @return [Boolean]
|
||||
def closed?; @closed; end
|
||||
|
||||
# Is this cursor alive on the server?
|
||||
#
|
||||
# @return [Boolean]
|
||||
def alive?
|
||||
@cursor_id && @cursor_id != 0
|
||||
end
|
||||
|
||||
# Returns an integer indicating which query options have been selected.
|
||||
#
|
||||
# @return [Integer]
|
||||
|
|
|
@ -32,6 +32,21 @@ class CursorTest < Test::Unit::TestCase
|
|||
assert_kind_of Numeric, explaination['nscanned']
|
||||
end
|
||||
|
||||
def test_alive
|
||||
batch = []
|
||||
5000.times do |n|
|
||||
batch << {:a => n}
|
||||
end
|
||||
@@coll.insert(batch)
|
||||
cursor = @@coll.find
|
||||
assert !cursor.alive?
|
||||
cursor.next
|
||||
assert cursor.alive?
|
||||
cursor.close
|
||||
assert !cursor.alive?
|
||||
@@coll.remove
|
||||
end
|
||||
|
||||
def test_count
|
||||
@@coll.remove
|
||||
|
||||
|
|
Loading…
Reference in New Issue