From 0257b2c2676a31ad81189fde730ea4082298dcb2 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Mon, 24 Jun 2024 15:52:50 +0200 Subject: [PATCH] we don't really need tests --- members/rest-queued/src/routes.rs | 69 ------------------------------- 1 file changed, 69 deletions(-) diff --git a/members/rest-queued/src/routes.rs b/members/rest-queued/src/routes.rs index 4e86eb7..da3740a 100644 --- a/members/rest-queued/src/routes.rs +++ b/members/rest-queued/src/routes.rs @@ -91,72 +91,3 @@ pub fn get_register( }) .boxed() } - -mod test { - use warp::{ - http::StatusCode, - hyper::{self, body::*}, - reply::{Json, Reply}, - }; - - use std::convert::From; - use std::str::FromStr; - use hyper::body::Bytes; - - #[tokio::test] - async fn test_register_and_get() { - let store = crate::Store::new(); - let filter = super::get_register(store.clone()); - - let response: warp::reply::Response = warp::test::request() - .path("/api/v1/register") - .filter(&filter) - .await - .unwrap() - .into_response(); - - assert_eq!(response.status(), StatusCode::OK); - let body_raw = hyper::body::to_bytes(response.into_body()).await.unwrap(); - let body_json: serde_json::Value = serde_json::from_slice(&body_raw).unwrap(); - - assert!(body_json.is_object()); - let id: crate::Id = crate::Id::from_str( - &body_json - .get("id") - .expect("response has no field 'id'") - .to_owned() - .to_string(), - ) - .unwrap(); - let token: crate::Token = crate::Token::from_str( - &body_json - .get("token") - .expect("response has no field 'token'") - .to_owned() - .to_string(), - ) - .unwrap(); - - assert_eq!(id.len(), crate::ID_LEN); - assert_eq!(token.len(), crate::TOK_LEN); - - let filter = super::get_items(store); - let response: warp::reply::Response = warp::test::request() - .path(format!("/api/v1/items/?id={id}").as_str()) - .header("Token", token.to_string()) - .filter(&filter) - .await - .unwrap() - .into_response(); - assert_eq!(response.status(), StatusCode::OK); - let body_raw = hyper::body::to_bytes(response.into_body()).await.unwrap(); - let body_json: serde_json::Value = serde_json::from_slice(&body_raw).unwrap(); - assert!(body_json.is_array()); - - for i in 0..2 { - assert!(body_json[i].is_object()); - let item: crate::Item = serde_json::from_value(body_json[i].clone().take()).unwrap(); - assert_eq!(item.seq, i); - } - } -}