@@ -114,8 +114,9 @@ async fn router_handles_basic_request() {
114114 . expect ( "read response body" ) ;
115115 let body_str = String :: from_utf8 ( body. to_vec ( ) ) . expect ( "parse response body as string" ) ;
116116
117- // The response should contain the processed message from HttpEndpoint
118- assert ! ( body_str. contains( "BasicEndpoint processed the request" ) ) ;
117+ // The response should contain the computed subpath from HttpEndpoint
118+ let json: serde_json:: Value = serde_json:: from_str ( & body_str) . expect ( "json" ) ;
119+ assert_eq ! ( json[ "path" ] , "get-route" ) ;
119120}
120121
121122#[ tokio:: test]
@@ -184,8 +185,8 @@ async fn router_selects_correct_endpoint_based_on_path() {
184185 let body = axum:: body:: to_bytes ( response. into_body ( ) , usize:: MAX )
185186 . await
186187 . expect ( "read response body" ) ;
187- let body_str = String :: from_utf8 ( body. to_vec ( ) ) . expect ( "parse response body as string " ) ;
188- assert ! ( body_str . contains ( "BasicEndpoint processed the request" ) ) ;
188+ let json : serde_json :: Value = serde_json :: from_slice ( & body) . expect ( "json " ) ;
189+ assert_eq ! ( json [ "path" ] , "get-route" ) ;
189190
190191 // Test `/fhir/:path` endpoint
191192 let response = app
@@ -206,8 +207,8 @@ async fn router_selects_correct_endpoint_based_on_path() {
206207 let body = axum:: body:: to_bytes ( response. into_body ( ) , usize:: MAX )
207208 . await
208209 . expect ( "read response body" ) ;
209- let body_str = String :: from_utf8 ( body. to_vec ( ) ) . expect ( "parse response body as string " ) ;
210- assert ! ( body_str . contains ( "FHIR endpoint received the request" ) ) ;
210+ let json : serde_json :: Value = serde_json :: from_slice ( & body) . expect ( "json " ) ;
211+ assert_eq ! ( json [ "path" ] , "patient" ) ;
211212
212213 // Test a non-existent route
213214 let response = app
@@ -286,7 +287,8 @@ async fn router_handles_path_based_routing() {
286287 . await
287288 . expect ( "read response body" ) ;
288289 let body_str = String :: from_utf8 ( body. to_vec ( ) ) . expect ( "parse response body as string" ) ;
289- assert ! ( body_str. contains( "Echo endpoint received the request" ) ) ;
290+ let json: serde_json:: Value = serde_json:: from_str ( & body_str) . expect ( "json" ) ;
291+ assert_eq ! ( json[ "path" ] , "test" ) ;
290292
291293 // Test second endpoint `/echo2/:path`
292294 let response = app
@@ -307,7 +309,8 @@ async fn router_handles_path_based_routing() {
307309 . await
308310 . expect ( "read response body" ) ;
309311 let body_str = String :: from_utf8 ( body. to_vec ( ) ) . expect ( "parse response body as string" ) ;
310- assert ! ( body_str. contains( "Echo endpoint received the request" ) ) ;
312+ let json: serde_json:: Value = serde_json:: from_str ( & body_str) . expect ( "json" ) ;
313+ assert_eq ! ( json[ "path" ] , "test" ) ;
311314
312315 // Test non-existent route
313316 let response = app
0 commit comments