Skip to content

Commit

Permalink
Fix write body test
Browse files Browse the repository at this point in the history
  • Loading branch information
mgattozzi committed Nov 15, 2022
1 parent e24c9b4 commit 3421a53
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
26 changes: 13 additions & 13 deletions cli/tests/integration/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async fn async_io_methods() -> TestResult {
.unwrap()
}
3 => {
let _body = req.into_body();
let _body = hyper::body::to_bytes(req.into_body()).await;
Response::builder()
.status(StatusCode::OK)
.body(Body::empty())
Expand Down Expand Up @@ -196,28 +196,28 @@ async fn async_io_methods() -> TestResult {
let _task = tokio::task::spawn(async move { temp_barrier.wait().await });
barrier.wait().await;

// let resp = test
// .against(
// Request::builder()
// .header("Host", "example.org")
// .header("Empty-Select-Timeout", "0")
// .body(vec![])
// .unwrap(),
// )
// .await;
// assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR);
let resp = test
.against(
Request::builder()
.header("Host", "example.org")
.header("Empty-Select-Timeout", "0")
.body(Body::empty())
.unwrap(),
)
.await;
assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR);

// let resp = test
// .against(
// Request::builder()
// .header("Host", "example.org")
// .header("Empty-Select-Timeout", "0")
// .body(vec![])
// .body(Body::empty())
// .unwrap(),
// )
// .await;
// assert_eq!(resp.status(), StatusCode::OK);
// assert_eq!(resp.headers()["Ready-Index"], "timeout");

//
Ok(())
}
8 changes: 5 additions & 3 deletions lib/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,13 @@ impl Session {
pub fn reinsert_pending_request(
&mut self,
handle: PendingRequestHandle,
pending_req: PendingRequest
pending_req: PendingRequest,
) -> Result<(), HandleError> {
*self.async_items
*self
.async_items
.get_mut(handle.into())
.ok_or(HandleError::InvalidPendingRequestHandle(handle))? = Some(AsyncItem::PendingReq(pending_req));
.ok_or(HandleError::InvalidPendingRequestHandle(handle))? =
Some(AsyncItem::PendingReq(pending_req));
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion test-fixtures/src/bin/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn test_select() -> Result<(), Error> {
append_header(&mut ds_resp, "Write-Ready", is_ready(write_body_handle));

let handles = vec![
s128imple_pending_req_handle,
simple_pending_req_handle,
read_body_handle,
write_body_handle,
];
Expand Down

0 comments on commit 3421a53

Please sign in to comment.