@@ -241,6 +241,46 @@ async fn stop_number_returns_single_route_ignoring_case(db: PgPool) {
241241 assert_that ( body) . contains ( expected_body) ;
242242}
243243
244+ #[ sqlx:: test( fixtures( "numbers-approved" ) ) ]
245+ async fn stop_number_notes_no_matching_routes ( db : PgPool ) {
246+ let mock_winnipeg_transit_api = MockServer :: start ( ) . await ;
247+ let mock_stop_schedule_response = fs:: read_to_string ( "tests/fixtures/times/stop_schedule.json" )
248+ . expect ( "Failed to read stop schedule fixture" ) ;
249+
250+ Mock :: given ( method ( "GET" ) )
251+ . and ( path_regex ( r"^/v4/stops/.*/schedule.json$" ) )
252+ . respond_with (
253+ ResponseTemplate :: new ( 200 ) . set_body_string ( mock_stop_schedule_response. clone ( ) ) ,
254+ )
255+ . expect ( 1 )
256+ . mount ( & mock_winnipeg_transit_api)
257+ . await ;
258+
259+ let response = get (
260+ "/twilio?Body=10619 99&From=approved&To=textabus&MessageSid=SM1849" ,
261+ InjectableServices {
262+ db : db. clone ( ) ,
263+ twilio_address : None ,
264+ winnipeg_transit_api_address : Some ( mock_winnipeg_transit_api. uri ( ) ) ,
265+ } ,
266+ )
267+ . await
268+ . expect ( "Failed to execute request" ) ;
269+
270+ assert ! ( response. status( ) . is_success( ) ) ;
271+ assert_eq ! ( response. headers( ) [ "content-type" ] , "text/xml" ) ;
272+
273+ let document = Document :: from ( response. text ( ) . await . unwrap ( ) . as_str ( ) ) ;
274+ let body = & document. find ( Name ( "body" ) ) . next ( ) . unwrap ( ) . text ( ) ;
275+
276+ let expected_body = indoc ! { "
277+ 10619 WB Graham@Vaughan (The Bay)
278+ No routes found matching 99 at this stop
279+ " } ;
280+
281+ assert_that ( body) . contains ( expected_body) ;
282+ }
283+
244284#[ sqlx:: test( fixtures( "numbers-approved" ) ) ]
245285async fn incorrect_stop_number_returns_error ( db : PgPool ) {
246286 let mock_winnipeg_transit_api = MockServer :: start ( ) . await ;
0 commit comments