Skip to content

Commit b45ec83

Browse files
committed
Raise error if update request is nil
1 parent 0308734 commit b45ec83

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

app/jobs/v3/services/update_broker_job.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class Perform
4747
def initialize(update_request_guid, previous_broker_state, user_audit_info:)
4848
@update_request_guid = update_request_guid
4949
@update_request = ServiceBrokerUpdateRequest.find(guid: update_request_guid)
50+
raise 'Service broker update request not found' if @update_request.nil?
51+
5052
@broker = ServiceBroker.find(id: @update_request.service_broker_id)
5153
@previous_broker_state = previous_broker_state
5254
@catalog_updater = VCAP::CloudController::V3::ServiceBrokerCatalogUpdater.new(@broker, user_audit_info:)

spec/unit/jobs/v3/services/update_broker_job_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,16 @@ module V3
491491
end
492492
end
493493

494+
context 'when the update request is deleted before job runs' do
495+
before do
496+
allow(ServiceBrokerUpdateRequest).to receive(:find).with(guid: update_broker_request.guid).and_return(nil)
497+
end
498+
499+
it 'raises an error with a clear message' do
500+
expect { job.perform }.to raise_error(RuntimeError, 'Service broker update request not found')
501+
end
502+
end
503+
494504
def setup_broker_with_invalid_catalog
495505
catalog = instance_double(Services::ServiceBrokers::V2::Catalog)
496506

0 commit comments

Comments
 (0)