activewarehouse / activewarehouse-etl

Extract-Transform-Load library from ActiveWarehouse
MIT License
240 stars 102 forks source link

Rows should not be processed anymore once error threshold is reached #46

Open thbar opened 13 years ago

thbar commented 13 years ago

Currently when the error threshold is reached, the remaining rows are still processed (see test-case below).

I believe the original intent was to stop processing remaining rows, reading the code.

require File.dirname(__FILE__) + '/test_helper'

class EngineTest < Test::Unit::TestCase

  context 'process' do

    should 'stop as soon as the error threshold is reached' do
      engine = ETL::Engine.new

      assert_equal 0, engine.errors.size

      engine.process ETL::Control::Control.parse_text <<CTL
        set_error_threshold 1
        source :in, { :type => :enumerable, :enumerable => (1..100) }
        after_read { |row| raise "Failure" }
CTL

      # will fail because engine.errors.size is 100
      assert_equal 1, engine.errors.size
    end

  end

end
thbar commented 13 years ago

The behaviour is caused by surrounding "Benchmark.realtime do" blocks in engine.rb.

At this point I will defer fixing this and will instead rewrite the engine later on.