(func: F)
| 719 | } |
| 720 | |
| 721 | async fn run_panicking_handler<F>(func: F) -> Result<(), Error> |
| 722 | where |
| 723 | F: FnMut(crate::LambdaEvent<serde_json::Value>) -> BoxFuture<'static, Result<serde_json::Value, Error>> |
| 724 | + Send |
| 725 | + 'static, |
| 726 | { |
| 727 | let server = MockServer::start(); |
| 728 | let request_id = "156cb537-e2d4-11e8-9b34-d36013741fb9"; |
| 729 | let deadline = "1542409706888"; |
| 730 | |
| 731 | let next_request = server.mock(|when, then| { |
| 732 | when.method(GET).path("/2018-06-01/runtime/invocation/next"); |
| 733 | then.status(200) |
| 734 | .header("content-type", "application/json") |
| 735 | .header("lambda-runtime-aws-request-id", request_id) |
| 736 | .header("lambda-runtime-deadline-ms", deadline) |
| 737 | .body("{}"); |
| 738 | }); |
| 739 | |
| 740 | let next_response = server.mock(|when, then| { |
| 741 | when.method(POST) |
| 742 | .path(format!("/2018-06-01/runtime/invocation/{request_id}/error")) |
| 743 | .header("lambda-runtime-function-error-type", "unhandled"); |
| 744 | then.status(200).body(""); |
| 745 | }); |
| 746 | |
| 747 | let base = server.base_url().parse().expect("Invalid mock server Uri"); |
| 748 | let client = Client::builder().with_endpoint(base).build()?; |
| 749 | |
| 750 | let f = crate::service_fn(func); |
| 751 | |
| 752 | let config = Arc::new(Config { |
| 753 | function_name: "test_fn".to_string(), |
| 754 | memory: 128, |
| 755 | version: "1".to_string(), |
| 756 | log_stream: "test_stream".to_string(), |
| 757 | log_group: "test_log".to_string(), |
| 758 | }); |
| 759 | |
| 760 | let client = Arc::new(client); |
| 761 | let runtime = Runtime { |
| 762 | client: client.clone(), |
| 763 | config, |
| 764 | service: wrap_handler(f, client), |
| 765 | concurrency_limit: 1, |
| 766 | }; |
| 767 | let client = &runtime.client; |
| 768 | let incoming = incoming(client).take(1); |
| 769 | Runtime::run_with_incoming(runtime.service, runtime.config, incoming).await?; |
| 770 | |
| 771 | next_request.assert_async().await; |
| 772 | next_response.assert_async().await; |
| 773 | Ok(()) |
| 774 | } |
| 775 | |
| 776 | #[tokio::test] |
| 777 | async fn panic_in_async_run() -> Result<(), Error> { |
no test coverage detected