mcookie: read from stdin if file is - (#279)

* read from stdin

* Update mcookie.rs

* test

* fmt

* Update mcookie.rs

* Update mcookie.rs
This commit is contained in:
Quang
2025-04-05 08:03:13 -07:00
committed by GitHub
parent 2da1a5f6fd
commit f24471694c
2 changed files with 53 additions and 19 deletions

View File

@@ -123,3 +123,20 @@ fn test_invalid_size_format() {
res.stderr_contains("Failed to parse max-size value");
}
#[test]
fn test_stdin_input() {
const INPUT_DATA: &str = "some test data for stdin";
let res = new_ucmd!()
.arg("--verbose")
.arg("-f")
.arg("-")
.pipe_in(INPUT_DATA)
.succeeds();
res.stderr_contains(format!("Got {} bytes from stdin", INPUT_DATA.len()));
let stdout = res.stdout_str().trim_end();
assert_eq!(stdout.len(), 32);
assert!(stdout.chars().all(|c| c.is_ascii_hexdigit()));
}