Sha256: 7238b73dbf3856701809a150ad84fc60adfe430b1d80cd5fb22ba9ed04fe108f

Contents?: true

Size: 800 Bytes

Versions: 41

Compression:

Stored size: 800 Bytes

Contents

require 'test_helper'

class CassandraObject::BatchesTest < CassandraObject::TestCase
  test 'find_each' do
    Issue.create 
    Issue.create 

    issues = []
    Issue.find_each do |issue|
      issues << issue
    end

    assert_equal Issue.all.to_set, issues.to_set
  end

  test 'find_in_batches' do
    Issue.create 
    Issue.create
    Issue.create

    issue_batches = []
    Issue.find_in_batches(batch_size: 2) do |issues|
      issue_batches << issues
    end

    assert_equal 2, issue_batches.size
    assert issue_batches.any? { |issues| issues.size == 2 }
    assert issue_batches.any? { |issues| issues.size == 1 }
  end

  test 'batch' do
    Issue.batch do
      Issue.create
      Issue.create
      assert_equal 0, Issue.count
    end

    assert_equal 2, Issue.count
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
gotime-cassandra_object-3.0.5 test/unit/batches_test.rb
gotime-cassandra_object-3.0.4 test/unit/batches_test.rb
gotime-cassandra_object-3.0.3 test/unit/batches_test.rb
gotime-cassandra_object-3.0.2 test/unit/batches_test.rb
gotime-cassandra_object-3.0.1 test/unit/batches_test.rb
gotime-cassandra_object-3.0.0 test/unit/batches_test.rb
gotime-cassandra_object-2.13.0 test/unit/batches_test.rb
gotime-cassandra_object-2.12.5 test/unit/batches_test.rb
gotime-cassandra_object-2.12.4 test/unit/batches_test.rb
gotime-cassandra_object-2.12.3 test/unit/batches_test.rb
gotime-cassandra_object-2.12.2 test/unit/batches_test.rb
gotime-cassandra_object-2.12.1 test/unit/batches_test.rb
gotime-cassandra_object-2.12.0 test/unit/batches_test.rb
gotime-cassandra_object-2.11.9 test/unit/batches_test.rb
gotime-cassandra_object-2.11.8 test/unit/batches_test.rb
gotime-cassandra_object-2.11.7 test/unit/batches_test.rb
gotime-cassandra_object-2.11.6 test/unit/batches_test.rb
gotime-cassandra_object-2.11.5 test/unit/batches_test.rb
gotime-cassandra_object-2.11.4 test/unit/batches_test.rb
gotime-cassandra_object-2.11.3 test/unit/batches_test.rb