mirror of
https://github.com/FliegendeWurst/ripgrep-all.git
synced 2024-11-08 22:10:37 +00:00
add tar test
This commit is contained in:
parent
c4dbabaf10
commit
2d28651bcb
BIN
exampledir/test/hello.tar
Normal file
BIN
exampledir/test/hello.tar
Normal file
Binary file not shown.
@ -94,20 +94,37 @@ impl FileAdapter for TarAdapter {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test_utils::*;
|
use crate::{preproc::loop_adapt, test_utils::*};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use tokio::fs::File;
|
use tokio::fs::File;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_simple_tar() -> Result<()> {
|
async fn test_simple_tar() -> Result<()> {
|
||||||
let filepath = test_data_dir().join("test.tar");
|
let filepath = test_data_dir().join("hello.tar");
|
||||||
|
|
||||||
let (a, d) = simple_adapt_info(&filepath, Box::pin(File::open(&filepath).await?));
|
let (a, d) = simple_adapt_info(&filepath, Box::pin(File::open(&filepath).await?));
|
||||||
|
|
||||||
let adapter = TarAdapter::new();
|
let adapter = TarAdapter::new();
|
||||||
let r = adapter.adapt(a, &d)?;
|
let r = loop_adapt(&adapter, d, a).context("adapt")?;
|
||||||
let o = adapted_to_vec(r).await?;
|
let o = adapted_to_vec(r).await.context("adapted_to_vec")?;
|
||||||
assert_eq!(String::from_utf8(o)?, "hello\n");
|
assert_eq!(
|
||||||
|
String::from_utf8(o).context("parsing utf8")?,
|
||||||
|
"PREFIX:dir/file-b.pdf: Page 1:hello world
|
||||||
|
PREFIX:dir/file-b.pdf: Page 1:this is just a test.
|
||||||
|
PREFIX:dir/file-b.pdf: Page 1:
|
||||||
|
PREFIX:dir/file-b.pdf: Page 1:1
|
||||||
|
PREFIX:dir/file-b.pdf: Page 1:
|
||||||
|
PREFIX:dir/file-b.pdf: Page 1:
|
||||||
|
PREFIX:dir/file-b.pdf: Page 2:
|
||||||
|
PREFIX:dir/file-a.pdf: Page 1:hello world
|
||||||
|
PREFIX:dir/file-a.pdf: Page 1:this is just a test.
|
||||||
|
PREFIX:dir/file-a.pdf: Page 1:
|
||||||
|
PREFIX:dir/file-a.pdf: Page 1:1
|
||||||
|
PREFIX:dir/file-a.pdf: Page 1:
|
||||||
|
PREFIX:dir/file-a.pdf: Page 1:
|
||||||
|
PREFIX:dir/file-a.pdf: Page 2:
|
||||||
|
"
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user