Sha256: 7a50cb4b78d5a6f144340586009e0985c4c95b80a6c6a337d550f9ffd8049313

Contents?: true

Size: 1.95 KB

Versions: 22

Compression:

Stored size: 1.95 KB

Contents

# Copyright (c) 2011 - 2013, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias
# Schmidt

require File.expand_path(File.dirname(__FILE__)) + '/unit_helper'

describe Lhm::ChunkFinder do
  before(:each) do
    @origin = Lhm::Table.new('foo')
    @destination = Lhm::Table.new('bar')
    @migration = Lhm::Migration.new(@origin, @destination)
    @connection = mock()
  end

  describe '#validate' do
    describe 'when start is greater than limit' do
      it 'raises' do
        assert_raises { Lhm::ChunkFinder.new(@connection, @migration, {start: 2, limit: 1}).validate }
      end
    end

    describe 'when start is greater than limit' do
      it 'does not raise' do
        Lhm::ChunkFinder.new(@connection, @migration, {start: 1, limit: 2}).validate # does not raise
      end
    end
  end

  describe '#start' do
    describe 'when initialized with 5' do
      before(:each) do
        @instance = Lhm::ChunkFinder.new(@connection, @migration, {start: 5, limit: 6})
      end

      it 'returns 5' do
        assert_equal @instance.start, 5
      end
    end

    describe 'when initialized with nil and the min(id) is 22' do
      before(:each) do
        @connection.expects(:select_value).returns(22)
        @instance = Lhm::ChunkFinder.new(@migration, @connection, {limit: 6})
      end

      it 'returns 22' do
        assert_equal @instance.start, 22
      end
    end
  end

  describe '#limit' do
    describe 'when initialized with 6' do
      before(:each) do
        @instance = Lhm::ChunkFinder.new(@connection, @migration, {start: 5, limit: 6})
      end

      it 'returns 6' do
        assert_equal @instance.limit, 6
      end
    end

    describe 'when initialized with nil and the max(id) is 33' do
      before(:each) do
        @connection.expects(:select_value).returns(33)
        @instance = Lhm::ChunkFinder.new(@migration, @connection, {start: 5})
      end

      it 'returns 33' do
        assert_equal @instance.limit, 33
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lhm-shopify-4.4.2 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.4.1 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.4.0 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.3.0 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.2.3 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.2.2 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.2.1 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.2.0 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.1.1 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.1.0 spec/unit/chunk_finder_spec.rb
lhm-shopify-4.0.0 spec/unit/chunk_finder_spec.rb
lhm-shopify-3.5.5 spec/unit/chunk_finder_spec.rb
lhm-shopify-3.5.4 spec/unit/chunk_finder_spec.rb
lhm-shopify-3.5.3 spec/unit/chunk_finder_spec.rb
lhm-shopify-3.5.2 spec/unit/chunk_finder_spec.rb
lhm-shopify-3.5.0 spec/unit/chunk_finder_spec.rb
lhm-shopify-3.5.1 spec/unit/chunk_finder_spec.rb
lhm-shopify-3.4.2 spec/unit/chunk_finder_spec.rb
lhm-shopify-3.4.1 spec/unit/chunk_finder_spec.rb
lhm-shopify-3.4.0 spec/unit/chunk_finder_spec.rb