Sha256: a772ae35b4637ba3d0019666c4fda3b3eb1832c7f6e3e7e6c5ce67831a3f260b
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
require 'helper' class TestPostgresqlCursor < Test::Unit::TestCase def test_cursor c = Model.find_with_cursor(:conditions=>["id>?",0], :cursor=>{:buffer_size=>10}) mycount=0 count = c.each { |r| mycount += 1 } assert_equal mycount, count end def test_empty_set c = Model.find_with_cursor(:conditions=>["id<?",0]) count = c.each { |r| puts r.class } assert_equal count, 0 end def test_block Model.transaction do c = Model.find_with_cursor(:conditions=>["id<?",10]) { |r| r } r = c.next assert_equal r.class, Hash end end def test_sql c = Model.find_by_sql_with_cursor("select * from #{Model.table_name}") mycount=0 count = c.each { |r| mycount += 1 } assert_equal mycount, count end def test_loop Model.transaction do cursor = Model.find_with_cursor() { |record| record.symbolize_keys } while record = cursor.next do assert record[:id].class, Fixnum cursor.close if cursor.count >= 10 end assert_equal cursor.count, 10 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
postgresql_cursor-0.3.1 | test/test_postgresql_cursor.rb |
postgresql_cursor-0.3.0 | test/test_postgresql_cursor.rb |
postgresql_cursor-0.2.0 | test/test_postgresql_cursor.rb |