Browse Source

Ensure we continue after a duplicate

tags/0.3.0^2
Bèr Kessels 1 year ago
parent
commit
aac75ff7ec
2 changed files with 17 additions and 0 deletions
  1. 2
    0
      bin/sink
  2. 15
    0
      test/integration/cli/sink_test.rb

+ 2
- 0
bin/sink View File

@@ -25,6 +25,8 @@ class EventSink
log(Logger::DEBUG, '-- parsed object')
command = Hours::AddPlaceCommand.build(obj)
Hours::CommandHandler.new.handle(command)
rescue Hours::DuplicateError => e
log(Logger::INFO, e.message)
end

def call(io)

+ 15
- 0
test/integration/cli/sink_test.rb View File

@@ -20,5 +20,20 @@ describe 'sink' do
assert_equal(last_event.body['properties'],
payload.fetch(:properties).transform_keys(&:to_s))
end

it 'logs duplicates and continues' do
status_list = Open3.pipeline(
['cat', fixtures('input/hm_broerstraat.json')],
[{ 'LOG_LEVEL' => '1' }, './bin/sink']
)
status_list.each { |status| assert status.success? }

stdout, stderr, status = Open3.capture3(
"cat #{fixtures('input/hm_broerstraat.json')} | LOG_LEVEL=1 ./bin/sink"
)
# Don't stop with an error
assert status.success?, "Expected success, got #{stderr}"
assert_match(/Place .* already exists/, stdout.to_s)
end
end
end

Loading…
Cancel
Save