mirror of
https://github.com/ducaale/xh.git
synced 2025-05-05 15:32:50 +00:00
add more test
This commit is contained in:
parent
70ad491c81
commit
2a1fba66f7
26
tests/cli.rs
26
tests/cli.rs
@ -3529,6 +3529,32 @@ fn compress_body_from_file() {
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compress_body_from_file_unless_compress_rate_less_1() {
|
||||
let server = server::http(|req| async move {
|
||||
assert_eq!("Hello world\n", req.body_as_string().await);
|
||||
hyper::Response::default()
|
||||
});
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let filename = dir.path().join("input.txt");
|
||||
OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.write(true)
|
||||
.open(&filename)
|
||||
.unwrap()
|
||||
.write_all(b"Hello world\n")
|
||||
.unwrap();
|
||||
|
||||
get_command()
|
||||
.arg(server.base_url())
|
||||
.arg("-x")
|
||||
.arg(format!("@{}", filename.to_string_lossy()))
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
fn zlib_decode(bytes: Vec<u8>) -> std::io::Result<String> {
|
||||
let mut z = flate2::read::ZlibDecoder::new(&bytes[..]);
|
||||
let mut s = String::new();
|
||||
|
Loading…
x
Reference in New Issue
Block a user