MCPcopy Index your code
hub / github.com/aws/aws-lambda-rust-runtime / test_error_response

Function test_error_response

lambda-runtime/src/runtime.rs:623–652  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

621
622 #[tokio::test]
623 async fn test_error_response() -> Result<(), Error> {
624 let diagnostic = Diagnostic {
625 error_type: "InvalidEventDataError".into(),
626 error_message: "Error parsing event data".into(),
627 };
628 let body = serde_json::to_string(&diagnostic)?;
629
630 let server = MockServer::start();
631 let mock = server.mock(|when, then| {
632 when.method(POST)
633 .path("/2018-06-01/runtime/invocation/156cb537-e2d4-11e8-9b34-d36013741fb9/error")
634 .header("lambda-runtime-function-error-type", "unhandled")
635 .body(body);
636 then.status(200).body("");
637 });
638
639 let base = server.base_url().parse().expect("Invalid mock server Uri");
640 let client = Client::builder().with_endpoint(base).build()?;
641
642 let req = EventErrorRequest {
643 request_id: "156cb537-e2d4-11e8-9b34-d36013741fb9",
644 diagnostic,
645 };
646 let req = req.into_req()?;
647 let rsp = client.call(req).await?;
648
649 mock.assert_async().await;
650 assert_eq!(rsp.status(), StatusCode::OK);
651 Ok(())
652 }
653
654 #[tokio::test]
655 async fn successful_end_to_end_run() -> Result<(), Error> {

Callers

nothing calls this directly

Calls 4

buildMethod · 0.80
with_endpointMethod · 0.80
into_reqMethod · 0.80
callMethod · 0.45

Tested by

no test coverage detected