add more test

This commit is contained in:
zuisong 2025-01-22 22:23:50 +08:00
parent 70ad491c81
commit 2a1fba66f7
No known key found for this signature in database
GPG Key ID: A617F31AFE6F5E8D

View File

@ -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();