From 2cfef413ea79885912a4d82ecddef7111517c427 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Aug 2024 17:00:27 +0100 Subject: [PATCH 1/2] fix: remove unused struct (#914) --- lambda-runtime/src/requests.rs | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/lambda-runtime/src/requests.rs b/lambda-runtime/src/requests.rs index 535f1e8e..729272f2 100644 --- a/lambda-runtime/src/requests.rs +++ b/lambda-runtime/src/requests.rs @@ -186,23 +186,6 @@ impl<'a> IntoRequest for EventErrorRequest<'a> { } } -// /runtime/init/error -struct InitErrorRequest; - -impl IntoRequest for InitErrorRequest { - fn into_req(self) -> Result, Error> { - let uri = "/2018-06-01/runtime/init/error".to_string(); - let uri = Uri::from_str(&uri)?; - - let req = build_request() - .method(Method::POST) - .uri(uri) - .header("lambda-runtime-function-error-type", "unhandled") - .body(Body::empty())?; - Ok(req) - } -} - #[cfg(test)] mod tests { use super::*; @@ -237,17 +220,4 @@ mod tests { None => false, }); } - - #[test] - fn test_init_error_request() { - let req = InitErrorRequest; - let req = req.into_req().unwrap(); - let expected = Uri::from_static("/2018-06-01/runtime/init/error"); - assert_eq!(req.method(), Method::POST); - assert_eq!(req.uri(), &expected); - assert!(match req.headers().get("User-Agent") { - Some(header) => header.to_str().unwrap().starts_with("aws-lambda-rust/"), - None => false, - }); - } } From 6bbd1c111cf9dd6182bc7817268f884bcc262e8c Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 12 Aug 2024 18:10:14 +0100 Subject: [PATCH 2/2] fix: bedrock tests (#915) --- .../src/event/bedrock_agent_runtime/mod.rs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lambda-events/src/event/bedrock_agent_runtime/mod.rs b/lambda-events/src/event/bedrock_agent_runtime/mod.rs index cf84d4d3..c1425b85 100644 --- a/lambda-events/src/event/bedrock_agent_runtime/mod.rs +++ b/lambda-events/src/event/bedrock_agent_runtime/mod.rs @@ -82,31 +82,34 @@ pub struct Agent { #[cfg(test)] mod tests { + + use crate::event::bedrock_agent_runtime::AgentEvent; + #[test] - #[cfg(feature = "bedrock-agent-runtime")] - fn example_bedrock_agent__runtime_event() { - let data = include!("../../fixtures/example-bedrock-agent-runtime-event.json"); - let parsed: AgentEvent = serde_json::from_str(&data).unwrap(); + #[cfg(feature = "bedrock_agent_runtime")] + fn example_bedrock_agent_runtime_event() { + let data = include_bytes!("../../fixtures/example-bedrock-agent-runtime-event.json"); + let parsed: AgentEvent = serde_json::from_slice(data).unwrap(); let output: String = serde_json::to_string(&parsed).unwrap(); - let reparsed: AgentEvent = serde_json::from_slice(&output.as_bytes()).unwrap(); + let reparsed: AgentEvent = serde_json::from_slice(output.as_bytes()).unwrap(); assert_eq!(parsed, reparsed); } #[test] - #[cfg(feature = "bedrock-agent-runtime")] + #[cfg(feature = "bedrock_agent_runtime")] fn example_bedrock_agent_runtime_event_without_parameters() { - let data = include!("../../fixtures/example-bedrock-agent-runtime-event-without-parameters.json"); - let parsed: AgentEvent = serde_json::from_str(&data).unwrap(); + let data = include_bytes!("../../fixtures/example-bedrock-agent-runtime-event-without-parameters.json"); + let parsed: AgentEvent = serde_json::from_slice(data).unwrap(); let output: String = serde_json::to_string(&parsed).unwrap(); - let reparsed: AgentEvent = serde_json::from_slice(&output.as_bytes()).unwrap(); + let reparsed: AgentEvent = serde_json::from_slice(output.as_bytes()).unwrap(); assert_eq!(parsed, reparsed); } #[test] - #[cfg(feature = "bedrock-agent-runtime")] + #[cfg(feature = "bedrock_agent_runtime")] fn example_bedrock_agent_runtime_event_without_request_body() { - let data = include!("../../fixtures/example-bedrock-agent-runtime-event-without-request-body.json"); - let parsed: AgentEvent = serde_json::from_str(&data).unwrap(); + let data = include_bytes!("../../fixtures/example-bedrock-agent-runtime-event-without-request-body.json"); + let parsed: AgentEvent = serde_json::from_slice(data).unwrap(); let output: String = serde_json::to_string(&parsed).unwrap(); - let reparsed: AgentEvent = serde_json::from_slice(&output.as_bytes()).unwrap(); + let reparsed: AgentEvent = serde_json::from_slice(output.as_bytes()).unwrap(); assert_eq!(parsed, reparsed); } }