Skip to content

Commit 1da1330

Browse files
committed
Use existing event-specific methods for pushing events to Redis
@joecorcoran added the methods in his initial work (PR #35) but I missed them at first. I think they're a better approach, since we can use them as a place to gather the metrics and logging we want to do around different events.
1 parent 3586c84 commit 1da1330

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

lib/travis/listener/app.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,15 @@ def sync_event
135135
type: event_type
136136
)
137137

138-
Travis::Sidekiq::GithubSync.push(Travis.config.sync.queue, data)
138+
case event_type
139+
when 'integration_installation'
140+
Travis::Sidekiq::GithubSync.gh_app_install(data)
141+
when 'installation_repositories'
142+
Travis::Sidekiq::GithubSync.gh_app_repos(data)
143+
else
144+
logger.info "Unable to find a sync event for event_type: #{event_type}"
145+
false
146+
end
139147
end
140148

141149
def handle_event?

spec/travis/events_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ def create(opts = {})
3030
it { expect(gatekeeper_queue).to have_received(:push).with('build_requests', hash_including(type: event)) }
3131
end
3232

33-
shared_examples_for 'queues gh sync event' do |&block|
34-
it { expect(gh_sync_queue)
35-
.to have_received(:push)
36-
.with('sync.gh_apps', hash_including(type: event)) }
37-
end
38-
3933
describe 'a push event' do
4034
let(:type) { 'push' }
4135
let(:event) { 'push' }
@@ -99,12 +93,18 @@ def create(opts = {})
9993
describe 'an integration_installation event' do
10094
let(:type) { 'integration_installation' }
10195
let(:event) { 'integration_installation' }
102-
include_examples 'queues gh sync event'
96+
97+
it { expect(gh_sync_queue)
98+
.to have_received(:push)
99+
.with('sync.gh_apps', :gh_app_install, hash_including(type: event)) }
103100
end
104101

105102
describe 'an installation_repositories event' do
106103
let(:type) { 'installation_repositories' }
107104
let(:event) { 'installation_repositories' }
108-
include_examples 'queues gh sync event'
105+
106+
it { expect(gh_sync_queue)
107+
.to have_received(:push)
108+
.with('sync.gh_apps', :gh_app_repos, hash_including(type: event)) }
109109
end
110110
end

0 commit comments

Comments
 (0)