Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kiba now defaults to "StreamingRunner" for processing jobs #83

Merged
merged 4 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/kiba.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
module Kiba
def self.run(job)
# NOTE: use Hash#dig when Ruby 2.2 reaches EOL
runner = job.config.fetch(:kiba, {}).fetch(:runner, Kiba::Runner)
runner = job.config.fetch(:kiba, {}).fetch(:runner, Kiba::StreamingRunner)
runner.run(job)
end
end
4 changes: 0 additions & 4 deletions test/shared_runner_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
require_relative 'support/test_destination_returning_nil'

module SharedRunnerTests
def kiba_run(job)
Kiba.run(job)
end

def rows
@rows ||= [
{ identifier: 'first-row' },
Expand Down
12 changes: 12 additions & 0 deletions test/test_run.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require_relative 'helper'
require 'minitest/mock'

class TestRun < Kiba::Test
def test_ensure_kiba_defaults_to_streaming_runner
cb = -> (job) { "Streaming runner called" }
Kiba::StreamingRunner.stub(:run, cb) do
job = Kiba::Control.new
assert_equal "Streaming runner called", Kiba.run(job)
end
end
end
5 changes: 5 additions & 0 deletions test/test_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
require_relative 'shared_runner_tests'

class TestRunner < Kiba::Test
def kiba_run(job)
job.config[:kiba] = {runner: Kiba::Runner}
Kiba.run(job)
end

include SharedRunnerTests
end
15 changes: 5 additions & 10 deletions test/test_streaming_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
require_relative 'shared_runner_tests'

class TestStreamingRunner < Kiba::Test
def kiba_run(job)
job.config[:kiba] = {runner: Kiba::StreamingRunner}
Kiba.run(job)
end

include SharedRunnerTests

def test_yielding_class_transform
input_row = {tags: ["one", "two", "three"]}
destination_array = []

job = Kiba.parse do
extend Kiba::DSLExtensions::Config

config :kiba, runner: Kiba::StreamingRunner

# provide a single row as the input
source TestEnumerableSource, [input_row]

Expand Down Expand Up @@ -51,9 +52,6 @@ def test_yielding_class_transform
def test_transform_yielding_from_close
destination_array = []
job = Kiba.parse do
extend Kiba::DSLExtensions::Config
config :kiba, runner: Kiba::StreamingRunner

transform CloseYieldingTransform, yield_on_close: [1, 2]
destination TestArrayDestination, destination_array
end
Expand All @@ -63,9 +61,6 @@ def test_transform_yielding_from_close

def test_transform_with_no_close_must_not_raise
job = Kiba.parse do
extend Kiba::DSLExtensions::Config
config :kiba, runner: Kiba::StreamingRunner

transform NonClosingTransform
end
Kiba.run(job)
Expand Down