Skip to content

Commit 832d435

Browse files
author
Christopher Skene
committed
Remove debug from tests
1 parent 6f7504c commit 832d435

6 files changed

Lines changed: 29 additions & 21 deletions

File tree

src/models/services/types/echo.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ impl ServiceHandler<Value> for EchoEndpoint {
8787
.unwrap_or_default();
8888

8989
envelope.normalized_data = Some(serde_json::json!({
90-
"message": "Echo endpoint received the request",
9190
"path": subpath,
9291
"full_path": full_path,
9392
"headers": envelope.request_details.headers,

src/models/services/types/fhir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ impl ServiceHandler<Value> for FhirEndpoint {
8787
.unwrap_or_default();
8888

8989
envelope.normalized_data = Some(serde_json::json!({
90-
"message": "FHIR endpoint received the request",
9190
"path": subpath,
9291
"full_path": full_path,
9392
"headers": envelope.request_details.headers,

src/models/services/types/http.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,25 @@ impl ServiceHandler<Value> for HttpEndpoint {
163163
mut envelope: RequestEnvelope<Vec<u8>>,
164164
_options: &HashMap<String, Value>,
165165
) -> Result<RequestEnvelope<Vec<u8>>, Error> {
166-
// Add or modify normalized data in the envelope
166+
// Populate normalized data with real request context
167+
let subpath = envelope
168+
.request_details
169+
.metadata
170+
.get("path")
171+
.cloned()
172+
.unwrap_or_default();
173+
let full_path = envelope
174+
.request_details
175+
.metadata
176+
.get("full_path")
177+
.cloned()
178+
.unwrap_or_default();
179+
167180
envelope.normalized_data = Some(serde_json::json!({
168-
"message": "BasicEndpoint processed the request",
169-
"original_data": envelope.original_data
181+
"path": subpath,
182+
"full_path": full_path,
183+
"headers": envelope.request_details.headers,
184+
"original_data": envelope.original_data,
170185
}));
171186

172187
Ok(envelope)

tests/fhir_service.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ async fn fhir_endpoint_handles_get_request() {
6565
.unwrap();
6666
let body = String::from_utf8(bytes.to_vec()).unwrap();
6767
let json: serde_json::Value = serde_json::from_str(&body).expect("json");
68-
assert_eq!(json["message"], "FHIR endpoint received the request");
6968
assert_eq!(json["path"], "patient/123");
7069
assert_eq!(json["full_path"], "/fhir/patient/123");
7170
assert!(json["headers"].is_object());
@@ -123,7 +122,6 @@ async fn fhir_put_is_supported() {
123122
.unwrap();
124123
let body = String::from_utf8(bytes.to_vec()).unwrap();
125124
let json: serde_json::Value = serde_json::from_str(&body).expect("json");
126-
assert_eq!(json["message"], "FHIR endpoint received the request");
127125
assert_eq!(json["path"], "Patient/123");
128126
assert_eq!(json["full_path"], "/fhir/Patient/123");
129127
assert!(json["headers"].is_object());
@@ -181,7 +179,6 @@ async fn fhir_delete_is_supported() {
181179
.unwrap();
182180
let body = String::from_utf8(bytes.to_vec()).unwrap();
183181
let json: serde_json::Value = serde_json::from_str(&body).expect("json");
184-
assert_eq!(json["message"], "FHIR endpoint received the request");
185182
assert_eq!(json["path"], "Patient/123");
186183
assert_eq!(json["full_path"], "/fhir/Patient/123");
187184
assert!(json["headers"].is_object());
@@ -244,7 +241,6 @@ async fn fhir_backend_is_invoked_in_pipeline() {
244241
.unwrap();
245242
let body = String::from_utf8(bytes.to_vec()).unwrap();
246243
let json: serde_json::Value = serde_json::from_str(&body).expect("json");
247-
assert_eq!(json["message"], "FHIR endpoint received the request");
248244
assert_eq!(json["path"], "Observation");
249245
assert_eq!(json["full_path"], "/fhir/Observation");
250246
assert!(json["headers"].is_object());

tests/router_runs.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

tests/smoke_http_echo.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ async fn smoke_http_get_echo_backend() {
8989
let json: serde_json::Value = serde_json::from_str(&body_str).expect("json");
9090
assert_eq!(json["path"], "ping");
9191
assert_eq!(json["full_path"], "/smoke/ping");
92-
assert_eq!(json["message"], "Echo endpoint received the request");
9392
assert!(json["headers"].is_object());
9493
}
9594

@@ -124,7 +123,6 @@ async fn smoke_http_post_echo_backend() {
124123
let json: serde_json::Value = serde_json::from_str(&body_str).expect("json");
125124
assert_eq!(json["path"], "echo");
126125
assert_eq!(json["full_path"], "/smoke/echo");
127-
assert_eq!(json["message"], "Echo endpoint received the request");
128126
assert!(json["headers"].is_object());
129127
}
130128

@@ -159,7 +157,6 @@ async fn smoke_http_put_echo_backend() {
159157
let json: serde_json::Value = serde_json::from_str(&body_str).expect("json");
160158
assert_eq!(json["path"], "resource/123");
161159
assert_eq!(json["full_path"], "/smoke/resource/123");
162-
assert_eq!(json["message"], "Echo endpoint received the request");
163160
assert!(json["headers"].is_object());
164161
}
165162

@@ -190,6 +187,5 @@ async fn smoke_http_delete_echo_backend() {
190187
let json: serde_json::Value = serde_json::from_str(&body_str).expect("json");
191188
assert_eq!(json["path"], "resource/123");
192189
assert_eq!(json["full_path"], "/smoke/resource/123");
193-
assert_eq!(json["message"], "Echo endpoint received the request");
194190
assert!(json["headers"].is_object());
195191
}

0 commit comments

Comments
 (0)