-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Run reqwest axum integration with coverage
- Loading branch information
Showing
3 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters