mirror of
https://github.com/FliegendeWurst/ripgrep-all.git
synced 2024-11-24 12:24:56 +00:00
Pin postproc_prefix
's StreamReader
and add unit test
This commit is contained in:
parent
1b97abfbca
commit
15a85275ef
@ -140,7 +140,7 @@ pub fn postproc_prefix(line_prefix: &str, inp: impl AsyncRead + Send) -> impl As
|
||||
}
|
||||
}
|
||||
};
|
||||
StreamReader::new(oup_stream)
|
||||
Box::pin(StreamReader::new(oup_stream))
|
||||
}
|
||||
|
||||
/// Adds the prefix "Page N:" to each line,
|
||||
@ -196,6 +196,18 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_postproc_prefix() {
|
||||
let mut output: Vec<u8> = Vec::new();
|
||||
let mock: Mock = Builder::new().read(b"Hello\nWorld").build();
|
||||
let res = postproc_prefix("prefix: ", mock)
|
||||
.read_to_end(&mut output)
|
||||
.await;
|
||||
println!("{}", String::from_utf8_lossy(&output));
|
||||
assert!(matches!(res, Ok(_)));
|
||||
assert_eq!(output, b"prefix: Hello\nprefix: World");
|
||||
}
|
||||
|
||||
async fn test_from_strs(
|
||||
pagebreaks: bool,
|
||||
line_prefix: &str,
|
||||
|
Loading…
Reference in New Issue
Block a user