diff --git a/car-mirror-reqwest/Cargo.toml b/car-mirror-reqwest/Cargo.toml index bdf995d..6df20fa 100644 --- a/car-mirror-reqwest/Cargo.toml +++ b/car-mirror-reqwest/Cargo.toml @@ -49,3 +49,7 @@ wnfs-unixfs-file = { workspace = true } all-features = true # defines the configuration attribute `docsrs` rustdoc-args = ["--cfg", "docsrs"] + +[[test]] +name = "integration" +path = "tests/integration.rs" diff --git a/car-mirror-reqwest/tests/integration.rs b/car-mirror-reqwest/tests/integration.rs new file mode 100644 index 0000000..557116e --- /dev/null +++ b/car-mirror-reqwest/tests/integration.rs @@ -0,0 +1,31 @@ +//! A copy of the doctest in lib.rs, because code coverage is buggy +//! with doctests. +use car_mirror::{cache::NoCache, common::Config}; +use car_mirror_reqwest::RequestBuilderExt; +use reqwest::Client; +use testresult::TestResult; +use wnfs_common::{BlockStore, MemoryBlockStore, CODEC_RAW}; + +#[test_log::test(tokio::test)] +async fn test_car_mirror_reqwest_axum_integration() -> TestResult { + tokio::spawn(car_mirror_axum::serve(MemoryBlockStore::new())); + + let store = MemoryBlockStore::new(); + let data = b"Hello, world!".to_vec(); + let root = store.put_block(data, CODEC_RAW).await?; + + let client = Client::new(); + client + .post(format!("http://localhost:3344/dag/push/{root}")) + .run_car_mirror_push(root, &store, &NoCache) + .await?; + + let store = MemoryBlockStore::new(); // clear out data + client + .post(format!("http://localhost:3344/dag/pull/{root}")) + .run_car_mirror_pull(root, &Config::default(), &store, &NoCache) + .await?; + + assert!(store.has_block(&root).await?); + Ok(()) +} diff --git a/car-mirror/src/dag_walk.rs b/car-mirror/src/dag_walk.rs index 045d0ec..510afd9 100644 --- a/car-mirror/src/dag_walk.rs +++ b/car-mirror/src/dag_walk.rs @@ -270,12 +270,12 @@ mod proptests { use futures::TryStreamExt; use libipld::{ multihash::{Code, MultihashDigest}, - Cid, Ipld, IpldCodec, + Ipld, IpldCodec, }; use proptest::strategy::Strategy; use std::collections::BTreeSet; use test_strategy::proptest; - use wnfs_common::{encode, BlockStore, MemoryBlockStore}; + use wnfs_common::{encode, MemoryBlockStore}; fn ipld_dags() -> impl Strategy, Cid)> { arb_ipld_dag(1..256, 0.5, |cids, _| {