From 6e69a1fffc715c752a399750c1e26aa46683dbb2 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 5 Feb 2024 14:44:12 +0100 Subject: [dep-upgrade-202402] prepare migration to http/hyper 1.0 --- src/garage/tests/k2v/batch.rs | 7 ++----- src/garage/tests/k2v/item.rs | 22 +++++----------------- src/garage/tests/k2v/poll.rs | 16 +++++----------- src/garage/tests/k2v/simple.rs | 9 +++------ 4 files changed, 15 insertions(+), 39 deletions(-) (limited to 'src/garage/tests/k2v') diff --git a/src/garage/tests/k2v/batch.rs b/src/garage/tests/k2v/batch.rs index 71de91bf..417fe7ea 100644 --- a/src/garage/tests/k2v/batch.rs +++ b/src/garage/tests/k2v/batch.rs @@ -7,7 +7,7 @@ use base64::prelude::*; use serde_json::json; use crate::json_body; -use hyper::{Method, StatusCode}; +use hyper::{body::HttpBody, Method, StatusCode}; #[tokio::test] async fn test_batch() { @@ -77,10 +77,7 @@ async fn test_batch() { .unwrap() .to_string(), ); - let res_body = hyper::body::to_bytes(res.into_body()) - .await - .unwrap() - .to_vec(); + let res_body = res.into_body().collect().await.unwrap().to_bytes(); assert_eq!(res_body, values.get(sk).unwrap().as_bytes()); } diff --git a/src/garage/tests/k2v/item.rs b/src/garage/tests/k2v/item.rs index 20add889..6b653088 100644 --- a/src/garage/tests/k2v/item.rs +++ b/src/garage/tests/k2v/item.rs @@ -7,7 +7,7 @@ use base64::prelude::*; use serde_json::json; use crate::json_body; -use hyper::{Method, StatusCode}; +use hyper::{body::HttpBody, Method, StatusCode}; #[tokio::test] async fn test_items_and_indices() { @@ -83,10 +83,7 @@ async fn test_items_and_indices() { .to_str() .unwrap() .to_string(); - let res_body = hyper::body::to_bytes(res.into_body()) - .await - .unwrap() - .to_vec(); + let res_body = res.into_body().collect().await.unwrap().to_bytes(); assert_eq!(res_body, content); // ReadIndex -- now there should be some stuff @@ -152,10 +149,7 @@ async fn test_items_and_indices() { res.headers().get("content-type").unwrap().to_str().unwrap(), "application/octet-stream" ); - let res_body = hyper::body::to_bytes(res.into_body()) - .await - .unwrap() - .to_vec(); + let res_body = res.into_body().collect().await.unwrap().to_bytes(); assert_eq!(res_body, content2); // ReadIndex -- now there should be some stuff @@ -394,10 +388,7 @@ async fn test_item_return_format() { .to_str() .unwrap() .to_string(); - let res_body = hyper::body::to_bytes(res.into_body()) - .await - .unwrap() - .to_vec(); + let res_body = res.into_body().collect().await.unwrap().to_bytes(); assert_eq!(res_body, single_value); // f1: not specified @@ -434,10 +425,7 @@ async fn test_item_return_format() { res.headers().get("content-type").unwrap().to_str().unwrap(), "application/octet-stream" ); - let res_body = hyper::body::to_bytes(res.into_body()) - .await - .unwrap() - .to_vec(); + let res_body = res.into_body().collect().await.unwrap().to_bytes(); assert_eq!(res_body, single_value); // f3: json diff --git a/src/garage/tests/k2v/poll.rs b/src/garage/tests/k2v/poll.rs index 452317c2..b75fa9c7 100644 --- a/src/garage/tests/k2v/poll.rs +++ b/src/garage/tests/k2v/poll.rs @@ -1,5 +1,5 @@ use base64::prelude::*; -use hyper::{Method, StatusCode}; +use hyper::{body::HttpBody, Method, StatusCode}; use std::time::Duration; use assert_json_diff::assert_json_eq; @@ -47,11 +47,8 @@ async fn test_poll_item() { .unwrap() .to_string(); - let res2_body = hyper::body::to_bytes(res2.into_body()) - .await - .unwrap() - .to_vec(); - assert_eq!(res2_body, b"Initial value"); + let res2_body = res2.into_body().collect().await.unwrap().to_bytes(); + assert_eq!(res2_body, b"Initial value"[..]); // Start poll operation let poll = { @@ -95,11 +92,8 @@ async fn test_poll_item() { assert_eq!(poll_res.status(), StatusCode::OK); - let poll_res_body = hyper::body::to_bytes(poll_res.into_body()) - .await - .unwrap() - .to_vec(); - assert_eq!(poll_res_body, b"New value"); + let poll_res_body = poll_res.into_body().collect().await.unwrap().to_bytes(); + assert_eq!(poll_res_body, b"New value"[..]); } #[tokio::test] diff --git a/src/garage/tests/k2v/simple.rs b/src/garage/tests/k2v/simple.rs index 465fc24d..a1d5008b 100644 --- a/src/garage/tests/k2v/simple.rs +++ b/src/garage/tests/k2v/simple.rs @@ -1,6 +1,6 @@ use crate::common; -use hyper::{Method, StatusCode}; +use hyper::{body::HttpBody, Method, StatusCode}; #[tokio::test] async fn test_simple() { @@ -32,9 +32,6 @@ async fn test_simple() { .unwrap(); assert_eq!(res2.status(), StatusCode::OK); - let res2_body = hyper::body::to_bytes(res2.into_body()) - .await - .unwrap() - .to_vec(); - assert_eq!(res2_body, b"Hello, world!"); + let res2_body = res2.into_body().collect().await.unwrap().to_bytes(); + assert_eq!(res2_body, b"Hello, world!"[..]); } -- cgit v1.2.3 From 81ccd4586ebdf707dfd37d4802e0cf475e11e004 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 5 Feb 2024 19:57:35 +0100 Subject: [dep-upgrade-202402] upgrade to http/hyper 1.x for tests --- src/garage/tests/k2v/batch.rs | 3 ++- src/garage/tests/k2v/item.rs | 3 ++- src/garage/tests/k2v/poll.rs | 3 ++- src/garage/tests/k2v/simple.rs | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/garage/tests/k2v') diff --git a/src/garage/tests/k2v/batch.rs b/src/garage/tests/k2v/batch.rs index 417fe7ea..39554d4d 100644 --- a/src/garage/tests/k2v/batch.rs +++ b/src/garage/tests/k2v/batch.rs @@ -7,7 +7,8 @@ use base64::prelude::*; use serde_json::json; use crate::json_body; -use hyper::{body::HttpBody, Method, StatusCode}; +use http_body_util::BodyExt; +use hyper::{Method, StatusCode}; #[tokio::test] async fn test_batch() { diff --git a/src/garage/tests/k2v/item.rs b/src/garage/tests/k2v/item.rs index 6b653088..5a347bd9 100644 --- a/src/garage/tests/k2v/item.rs +++ b/src/garage/tests/k2v/item.rs @@ -7,7 +7,8 @@ use base64::prelude::*; use serde_json::json; use crate::json_body; -use hyper::{body::HttpBody, Method, StatusCode}; +use http_body_util::BodyExt; +use hyper::{Method, StatusCode}; #[tokio::test] async fn test_items_and_indices() { diff --git a/src/garage/tests/k2v/poll.rs b/src/garage/tests/k2v/poll.rs index b75fa9c7..277f8bc8 100644 --- a/src/garage/tests/k2v/poll.rs +++ b/src/garage/tests/k2v/poll.rs @@ -1,5 +1,6 @@ use base64::prelude::*; -use hyper::{body::HttpBody, Method, StatusCode}; +use http_body_util::BodyExt; +use hyper::{Method, StatusCode}; use std::time::Duration; use assert_json_diff::assert_json_eq; diff --git a/src/garage/tests/k2v/simple.rs b/src/garage/tests/k2v/simple.rs index a1d5008b..1017330d 100644 --- a/src/garage/tests/k2v/simple.rs +++ b/src/garage/tests/k2v/simple.rs @@ -1,6 +1,7 @@ use crate::common; -use hyper::{body::HttpBody, Method, StatusCode}; +use http_body_util::BodyExt; +use hyper::{Method, StatusCode}; #[tokio::test] async fn test_simple() { -- cgit v1.2.3