@@ -43,6 +43,8 @@ module V3
4343
4444 describe '#precursor' do
4545 RSpec . shared_examples 'the credential binding precursor' do
46+ before { TestConfig . override ( max_service_credential_bindings_per_app_service_instance : 1 ) }
47+
4648 it 'returns a service credential binding precursor' do
4749 binding = action . precursor ( service_instance , app :, message :)
4850
@@ -69,9 +71,6 @@ module V3
6971 context 'when a binding already exists' do
7072 let! ( :binding ) { ServiceBinding . make ( service_instance :, app :) }
7173
72- # TODO: Once the unique constraints to allow multiple bindings are removed, this needs to be set to 1
73- # before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
74-
7574 context 'when no last binding operation exists' do
7675 it 'raises an error' do
7776 expect { action . precursor ( service_instance , app :, message :) } . to raise_error (
@@ -161,9 +160,6 @@ module V3
161160 end
162161 let ( :service_instance2 ) { ManagedServiceInstance . make ( **si_details ) }
163162
164- # TODO: Once the unique constraints to allow multiple bindings are removed, this needs to be set to 1
165- # before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
166-
167163 it 'raises an error when the binding name already exists' do
168164 # First request, should succeed
169165 expect do
@@ -188,9 +184,6 @@ module V3
188184 )
189185 end
190186
191- # TODO: Once the unique constraints to allow multiple bindings are removed, this needs to be set to 1
192- # before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
193-
194187 it 'raises an error when the app is already bound to the service instance' do
195188 # First request, should succeed
196189 expect do
@@ -209,8 +202,6 @@ module V3
209202 let ( :binding_1 ) { ServiceBinding . make ( service_instance : service_instance , app : app , name : nil ) }
210203
211204 before do
212- # TODO: Once the unique constraints to allow multiple bindings are removed, this needs to be set to 1
213- # TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1)
214205 binding_1 . save_with_attributes_and_new_operation ( { } , { type : 'create' , state : 'succeeded' } )
215206 end
216207
@@ -231,9 +222,6 @@ module V3
231222 context 'concurrent credential binding creation' do
232223 let ( :name ) { nil }
233224
234- # TODO: Once the unique constraints to allow multiple bindings are removed, this needs to be set to 1
235- # before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
236-
237225 it 'allows only one binding when two creates run in parallel' do
238226 # This test simulates a race condition for concurrent binding creation using a spy on `service_instance`.
239227 # We mock that a second binding is created after the first one acquires a lock and expect an `UnprocessableCreate` error.
@@ -251,11 +239,13 @@ module V3
251239 end
252240
253241 context 'when multiple bindings are allowed' do
242+ let ( :binding_1 ) { ServiceBinding . make ( service_instance :, app :, name :) }
243+
254244 before do
255245 # TODO: Remove skip when the service bindings unique constraints are removed
256246 skip 'this test can be enabled when the service bindings unique constraints are removed and max_bindings_per_app_service_instance can be configured'
257247
258- binding_1 = ServiceBinding . make ( service_instance : , app : , name : )
248+ TestConfig . override ( max_service_credential_bindings_per_app_service_instance : 3 )
259249 binding_2 = ServiceBinding . make ( service_instance :, app :, name :)
260250 binding_1 . save_with_attributes_and_new_operation ( { } , { type : 'create' , state : 'succeeded' } )
261251 binding_2 . save_with_attributes_and_new_operation ( { } , { type : 'create' , state : 'succeeded' } )
@@ -276,8 +266,6 @@ module V3
276266 end
277267
278268 it 'raises an error if one of the bindings is in a failed state' do
279- TestConfig . override ( max_service_credential_bindings_per_app_service_instance : 2 )
280-
281269 ServiceBinding . make ( service_instance :, app :, name :) . save_with_attributes_and_new_operation ( { } , { type : 'create' , state : 'succeeded' } )
282270 ServiceBinding . make ( service_instance :, app :, name :) . save_with_attributes_and_new_operation ( { } , { type : 'delete' , state : 'failed' } )
283271
@@ -304,8 +292,6 @@ module V3
304292 end
305293
306294 it 'raises an error if an existing binding has a different name' do
307- TestConfig . override ( max_service_credential_bindings_per_app_service_instance : 4 )
308-
309295 ServiceBinding . make ( service_instance : service_instance , app : app , name : 'other-name' ) .
310296 save_with_attributes_and_new_operation ( { } , { type : 'create' , state : 'succeeded' } )
311297
0 commit comments