test/embulk/input/test_mixpanel.rb in embulk-input-mixpanel-0.5.9 vs test/embulk/input/test_mixpanel.rb in embulk-input-mixpanel-0.5.10

- old
+ new

@@ -593,11 +593,36 @@ mock(@page_builder).add(["FOO", adjusted, "event"]).times(records.length * 2) mock(@page_builder).finish @plugin.run end + class PartialRunTest < self + def setup_client + any_instance_of(MixpanelApi::Client) do |klass| + stub(klass).request { raise MixpanelApi::IncompleteExportResponseError.new("Incomplete data received") } + end + end + def setup + setup_client() + @page_builder = Object.new + end + def test_run_with_allow_partial_false + @plugin = Mixpanel.new(task.merge(allow_partial_import: false), nil, nil, @page_builder) + stub(@plugin).preview? {false} + assert_raise MixpanelApi::IncompleteExportResponseError do + @plugin.run + end + end + + def test_run_with_allow_partial_true + @plugin = Mixpanel.new(task.merge(allow_partial_import: true), nil, nil, @page_builder) + mock(@page_builder).finish + stub(@plugin).preview? {false} + @plugin.run + end + end class SliceRangeRunTest < self def test_default_slice_range plugin = Mixpanel.new(task.merge(slice_range: 2), nil, nil, @page_builder) stub(plugin).preview? {false} @@ -723,11 +748,10 @@ mock(@page_builder).add(added).at_least(1) mock(@page_builder).finish @plugin.run end - private def task super.merge(schema: schema, fetch_unknown_columns: false, fetch_custom_properties: true) end @@ -832,10 +856,11 @@ retry_initial_wait_sec: 2, retry_limit: 3, latest_fetched_time: 0, slice_range: 7, job_start_time: JOB_START_TIME, - incremental_column_upper_limit: (JOB_START_TIME - UPPER_LIMIT_DELAY * 1000) + incremental_column_upper_limit: (JOB_START_TIME - UPPER_LIMIT_DELAY * 1000), + allow_partial_import: true } end def records [