()
| 560 | |
| 561 | #[tokio::test] |
| 562 | async fn test_next_event() -> Result<(), Error> { |
| 563 | let server = MockServer::start(); |
| 564 | let request_id = "156cb537-e2d4-11e8-9b34-d36013741fb9"; |
| 565 | let deadline = "1542409706888"; |
| 566 | |
| 567 | let mock = server.mock(|when, then| { |
| 568 | when.method(GET).path("/2018-06-01/runtime/invocation/next"); |
| 569 | then.status(200) |
| 570 | .header("content-type", "application/json") |
| 571 | .header("lambda-runtime-aws-request-id", request_id) |
| 572 | .header("lambda-runtime-deadline-ms", deadline) |
| 573 | .body("{}"); |
| 574 | }); |
| 575 | |
| 576 | let base = server.base_url().parse().expect("Invalid mock server Uri"); |
| 577 | let client = Client::builder().with_endpoint(base).build()?; |
| 578 | |
| 579 | let req = NextEventRequest.into_req()?; |
| 580 | let rsp = client.call(req).await.expect("Unable to send request"); |
| 581 | |
| 582 | mock.assert_async().await; |
| 583 | assert_eq!(rsp.status(), StatusCode::OK); |
| 584 | assert_eq!( |
| 585 | rsp.headers()["lambda-runtime-aws-request-id"], |
| 586 | &HeaderValue::from_static(request_id) |
| 587 | ); |
| 588 | assert_eq!( |
| 589 | rsp.headers()["lambda-runtime-deadline-ms"], |
| 590 | &HeaderValue::from_static(deadline) |
| 591 | ); |
| 592 | |
| 593 | let body = rsp.into_body().collect().await?.to_bytes(); |
| 594 | assert_eq!("{}", std::str::from_utf8(&body)?); |
| 595 | Ok(()) |
| 596 | } |
| 597 | |
| 598 | #[tokio::test] |
| 599 | async fn test_ok_response() -> Result<(), Error> { |
nothing calls this directly
no test coverage detected