spec/unit/chunker_spec.rb in lhm-2.1.0 vs spec/unit/chunker_spec.rb in lhm-2.2.0

- old
+ new

@@ -10,29 +10,29 @@ describe Lhm::Chunker do include UnitHelper before(:each) do - @origin = Lhm::Table.new("foo") - @destination = Lhm::Table.new("bar") + @origin = Lhm::Table.new('foo') + @destination = Lhm::Table.new('bar') @migration = Lhm::Migration.new(@origin, @destination) @connection = MiniTest::Mock.new # This is a poor man's stub @throttler = Object.new def @throttler.run - #noop + # noop end def @throttler.stride 1 end @chunker = Lhm::Chunker.new(@migration, @connection, :throttler => @throttler, :start => 1, :limit => 10) end - describe "#run" do - it "chunks the result set according to the stride size" do + describe '#run' do + it 'chunks the result set according to the stride size' do def @throttler.stride 2 end @connection.expect(:update, 2) do |stmt| @@ -53,12 +53,12 @@ @chunker.run @connection.verify end - it "handles stride changes during execution" do - #roll our own stubbing + it 'handles stride changes during execution' do + # roll our own stubbing def @throttler.stride @run_count ||= 0 @run_count = @run_count + 1 if @run_count > 1 3 @@ -82,13 +82,26 @@ @chunker.run @connection.verify end - it "separates filter conditions from chunking conditions" do + it 'correctly copies single record tables' do @chunker = Lhm::Chunker.new(@migration, @connection, :throttler => @throttler, :start => 1, + :limit => 1) + + @connection.expect(:update, 1) do |stmt| + stmt.first =~ /between 1 and 1/ + end + + @chunker.run + @connection.verify + end + + it 'separates filter conditions from chunking conditions' do + @chunker = Lhm::Chunker.new(@migration, @connection, :throttler => @throttler, + :start => 1, :limit => 2) @connection.expect(:update, 1) do |stmt| stmt.first =~ /where \(foo.created_at > '2013-07-10' or foo.baz = 'quux'\) and `foo`/ end @@ -108,10 +121,10 @@ puts stmt stmt.first =~ /inner join bar on foo.id = bar.foo_id and/ end def @migration.conditions - "inner join bar on foo.id = bar.foo_id" + 'inner join bar on foo.id = bar.foo_id' end @chunker.run @connection.verify end