refactor: tests under v0::tests
@@ -81,11 +81,16 @@ async fn not_implemented() -> Result<impl warp::Reply, std::convert::Infallible>
Ok(warp::http::StatusCode::NOT_IMPLEMENTED)
}
-/// Creates routes for tests, the ipfs will not work as no background task is being spawned.
#[cfg(test)]
-async fn non_functioning_routes(
+mod tests {
+ use std::convert::Infallible;
+
+ /// Creates routes for tests, the ipfs will not work as no background task is being spawned.
+ async fn testing_routes(
) -> impl warp::Filter<Extract = impl warp::Reply, Error = Infallible> + Clone {
+ use super::routes;
use ipfs::{IpfsOptions, TestTypes, UninitializedIpfs};
+
let options = IpfsOptions::<TestTypes>::default();
let (ipfs, fut) = UninitializedIpfs::new(options).await.start().await.unwrap();
@@ -97,8 +102,8 @@ async fn non_functioning_routes(
}
#[tokio::test]
-async fn not_found() {
- let routes = non_functioning_routes().await;
+ async fn not_found_as_plaintext() {
+ let routes = testing_routes().await;
let resp = warp::test::request()
.method("GET")
.path("/api/v0/id_foobar")
@@ -108,13 +113,11 @@ async fn not_found() {
assert_eq!(resp.status(), 404);
// from go-ipfs
assert_eq!(resp.body(), "404 page not found");
-
- println!("{:?}", resp);
}
#[tokio::test]
-async fn invalid_peer_id() {
- let routes = non_functioning_routes().await;
+ async fn invalid_peer_id_as_messageresponse() {
+ let routes = testing_routes().await;
let resp = warp::test::request()
.method("GET")
.path("/api/v0/id?arg=foobar")
@@ -127,6 +130,5 @@ async fn invalid_peer_id() {
resp.body(),
r#"{"Message":"invalid peer id","Code":0,"Type":"error"}"#
);
-
- println!("{:?}", resp);
+ }
}
