Skip to content

Commit 06f57ee

Browse files
committed
Apply review feedback
1 parent 8af0132 commit 06f57ee

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

app/actions/manifest_route_update.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def update(app_guid, message, user_audit_info)
2424
current_route = manifest_route_mapping[:route].to_s
2525
route = {
2626
model: find_or_create_valid_route(app, manifest_route_mapping[:route].to_hash, user_audit_info),
27-
protocol: manifest_route_mapping[:protocol]
27+
protocol: manifest_route_mapping[:protocol],
28+
route_string: current_route
2829
}
2930

3031
raise InvalidRoute.new("No domains exist for route #{current_route}") if route[:model].blank?
@@ -35,6 +36,7 @@ def update(app_guid, message, user_audit_info)
3536
# map route to app, but do this only if the full message contains valid routes
3637
routes_to_map.
3738
each do |route|
39+
current_route = route[:route_string]
3840
route_mapping = RouteMappingModel.find(app: app, route: route[:model])
3941
if route_mapping.nil?
4042
UpdateRouteDestinations.add(
@@ -57,6 +59,9 @@ def update(app_guid, message, user_audit_info)
5759
rescue Sequel::ValidationFailed, RouteCreate::Error, RouteUpdate::Error => e
5860
route_info = current_route ? "For route '#{current_route}': " : ''
5961
raise InvalidRoute.new("#{route_info}#{e.message}")
62+
rescue UpdateRouteDestinations::Error => e
63+
route_info = current_route ? "For route '#{current_route}': " : ''
64+
raise UpdateRouteDestinations::Error.new("#{route_info}#{e.message}")
6065
end
6166

6267
private

spec/unit/actions/manifest_route_update_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,10 @@ module VCAP::CloudController
312312
it 'throws an error' do
313313
expect do
314314
ManifestRouteUpdate.update(app.guid, message, user_audit_info)
315-
end.to raise_error(VCAP::CloudController::UpdateRouteDestinations::Error, 'Cannot use \'http2\' protocol for tcp routes; valid options are: [tcp].')
315+
end.to raise_error(
316+
VCAP::CloudController::UpdateRouteDestinations::Error,
317+
%r{For route 'http://tcp.tomato.avocado-toast.com:1234': Cannot use 'http2' protocol for tcp routes; valid options are: \[tcp\]}
318+
)
316319
end
317320
end
318321
end
@@ -492,7 +495,10 @@ module VCAP::CloudController
492495
it 'raises an error indicating hash_header is required' do
493496
expect do
494497
ManifestRouteUpdate.update(app.guid, message, user_audit_info)
495-
end.to raise_error(ManifestRouteUpdate::InvalidRoute, /Hash header must be present when loadbalancing is set to hash./)
498+
end.to raise_error(
499+
ManifestRouteUpdate::InvalidRoute,
500+
%r{For route 'http://potato.tomato.avocado-toast.com/some-path': Hash header must be present when loadbalancing is set to hash.}
501+
)
496502
end
497503
end
498504

0 commit comments

Comments
 (0)