refactor: remove the old repo tests
This commit is contained in:
parent
c38673ff3e
commit
bb5b756bfc
@ -442,92 +442,3 @@ impl<TRepoTypes: RepoTypes> Repo<TRepoTypes> {
|
||||
self.data_store.query(cids, requirement).await
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use std::env::temp_dir;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Types;
|
||||
|
||||
impl RepoTypes for Types {
|
||||
type TBlockStore = mem::MemBlockStore;
|
||||
type TDataStore = mem::MemDataStore;
|
||||
}
|
||||
|
||||
pub fn create_mock_repo() -> (Repo<Types>, Receiver<RepoEvent>) {
|
||||
let mut tmp = temp_dir();
|
||||
tmp.push("rust-ipfs-repo");
|
||||
let options: RepoOptions = RepoOptions { path: tmp };
|
||||
Repo::new(options)
|
||||
}
|
||||
|
||||
// Using boxed error here instead of anyhow to futureproof; we don't really care what goes
|
||||
// wrong here
|
||||
//
|
||||
// FIXME: how to duplicate this for each?
|
||||
async fn inited_repo() -> Result<
|
||||
Repo<Types>, /*, Receiver<RepoEvent>)*/
|
||||
Box<dyn std::error::Error + Send + Sync + 'static>,
|
||||
> {
|
||||
let (mock, rx) = create_mock_repo();
|
||||
drop(rx);
|
||||
mock.init().await?;
|
||||
|
||||
let (empty_cid, empty_file_block) = ipfs_unixfs::file::adder::FileAdder::default()
|
||||
.finish()
|
||||
.next()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
empty_cid.to_string(),
|
||||
"QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH"
|
||||
);
|
||||
|
||||
let empty_len = empty_file_block.len();
|
||||
|
||||
trace!("putting in empty block");
|
||||
mock.put_block(Block {
|
||||
cid: empty_cid.clone(),
|
||||
data: empty_file_block.into(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut tree_builder = ipfs_unixfs::dir::builder::BufferingTreeBuilder::default();
|
||||
|
||||
let empty_paths = [
|
||||
"root/nested/deeper/an_empty_file",
|
||||
"root/nested/deeper/another_empty",
|
||||
// clone is just a copy of deeper but it's easier to build by copypasting this
|
||||
"root/clone_of_deeper/an_empty_file",
|
||||
"root/clone_of_deeper/another_empty",
|
||||
];
|
||||
|
||||
empty_paths
|
||||
.iter()
|
||||
//.inspect(|p| println!("{:>50}: {}", p, empty_cid.clone()))
|
||||
.try_for_each(|p| tree_builder.put_link(p, empty_cid.clone(), empty_len as u64))
|
||||
.unwrap();
|
||||
|
||||
for node in tree_builder.build() {
|
||||
let node = node.unwrap();
|
||||
//println!("{:>50}: {}", node.path, node.cid);
|
||||
let block = Block {
|
||||
cid: node.cid,
|
||||
data: node.block,
|
||||
};
|
||||
|
||||
mock.put_block(block).await.unwrap();
|
||||
}
|
||||
|
||||
Ok(mock)
|
||||
}
|
||||
|
||||
#[tokio::test(max_threads = 1)]
|
||||
async fn smoke_test() {
|
||||
// not sure if this should be kept or be deleted
|
||||
inited_repo().await.unwrap();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user