Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

add a log line when the update job service receives the message #445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions lib/travis/services/update_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def run_completed
data: target.data
)
end
alias run_received run_completed
end
Instrument.attach_to(self)
end
Expand Down
4 changes: 3 additions & 1 deletion lib/travis/testing/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def call(code)

RSpec::Matchers.define :publish_instrumentation_event do |data|
match do |event|
non_matching = data.map { |key, value| [key, value, event[key]] unless event[key] == value }.compact
non_matching = data.map do |key, value|
[key, value, event[key]] unless value.is_a?(Regexp) && event[key] =~ value || event[key] == value
end.compact
expected_keys = [:uuid, :event, :started_at]
missing_keys = expected_keys.select { |key| !event.key?(key) }

Expand Down
25 changes: 25 additions & 0 deletions spec/travis/services/update_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,29 @@
job.reload.repository.last_build_started_at.should be_nil
end
end

describe 'the instrument' do
let(:publisher) { Travis::Notification::Publisher::Memory.new }
let(:event) { :start }

before :each do
Travis::Notification.publishers.replace([publisher])
end

it 'publishes a received event' do
service.run
publisher.events.first.should publish_instrumentation_event(
event: 'travis.services.update_job.run:received',
message: /Travis::Services::UpdateJob#run:received event: start for <Job id=#{job.id}>/
)
end

it 'publishes a completed event' do
service.run
publisher.events.last.should publish_instrumentation_event(
event: 'travis.services.update_job.run:completed',
message: /Travis::Services::UpdateJob#run:completed event: start for <Job id=#{job.id}>/,
)
end
end
end