Skip to content

Commit

Permalink
chore: Run reqwest axum integration with coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus23 committed Mar 4, 2024
1 parent 66bc2d6 commit daf6edb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
4 changes: 4 additions & 0 deletions car-mirror-reqwest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
31 changes: 31 additions & 0 deletions car-mirror-reqwest/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
4 changes: 2 additions & 2 deletions car-mirror/src/dag_walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Value = (Vec<(Cid, Ipld)>, Cid)> {
arb_ipld_dag(1..256, 0.5, |cids, _| {
Expand Down

0 comments on commit daf6edb

Please sign in to comment.