@@ -166,10 +166,24 @@ module CloudController
166166 ) . once
167167 end
168168
169- it 'sets the state to SYNCHRONIZING' do
169+ it 'does not immediately set the state to SYNCHRONIZING' do
170170 action . enqueue_update
171171
172- expect ( existing_service_broker . state ) . to eq ( ServiceBrokerStateEnum ::SYNCHRONIZING )
172+ expect ( existing_service_broker . state ) . to eq ( ServiceBrokerStateEnum ::AVAILABLE )
173+ end
174+
175+ it 'sets the state to SYNCHRONIZING when the job runs' do
176+ action . enqueue_update
177+
178+ broker_state_during_execution = nil
179+ allow_any_instance_of ( VCAP ::CloudController ::V3 ::ServiceBrokerCatalogUpdater ) . to receive ( :refresh ) do
180+ broker_state_during_execution = existing_service_broker . reload . state
181+ nil
182+ end
183+
184+ execute_all_jobs ( expected_successes : 1 , expected_failures : 0 )
185+ expect ( broker_state_during_execution ) . to eq ( ServiceBrokerStateEnum ::SYNCHRONIZING )
186+ expect ( existing_service_broker . reload . state ) . to eq ( ServiceBrokerStateEnum ::AVAILABLE )
173187 end
174188
175189 it 'creates an audit event' do
@@ -237,10 +251,24 @@ module CloudController
237251 context 'legacy service brokers' do
238252 let! ( :state ) { '' } # broker creating from V2 endpoint will not have a state
239253
240- it 'sets the state to SYNCHRONIZING' do
254+ it 'does not immediately set the state to SYNCHRONIZING' do
241255 action . enqueue_update
242256
243- expect ( existing_service_broker . reload . state ) . to eq ( ServiceBrokerStateEnum ::SYNCHRONIZING )
257+ expect ( existing_service_broker . reload . state ) . to eq ( '' )
258+ end
259+
260+ it 'sets the state to SYNCHRONIZING when the job runs' do
261+ action . enqueue_update
262+
263+ broker_state_during_execution = nil
264+ allow_any_instance_of ( VCAP ::CloudController ::V3 ::ServiceBrokerCatalogUpdater ) . to receive ( :refresh ) do
265+ broker_state_during_execution = existing_service_broker . reload . state
266+ nil
267+ end
268+
269+ execute_all_jobs ( expected_successes : 1 , expected_failures : 0 )
270+ expect ( broker_state_during_execution ) . to eq ( ServiceBrokerStateEnum ::SYNCHRONIZING )
271+ expect ( existing_service_broker . reload . state ) . to eq ( ServiceBrokerStateEnum ::AVAILABLE )
244272 end
245273
246274 it 'creates and returns a synchronization job' do
0 commit comments