-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Currently, minify_sql_to_string only works on file paths, to test it (and maybe fuzz it) it would be great to have a version that work on a generic input that implements std::io::Read and writes on something that implements std::io::Write.
Like:
pub fn minify_sql(input: impl std::io::Read, output: &mut impl std::io::Write) -> Result<(), std::io::Error> {
...
}This would be great for tests, as you could use a std::io::Cursor to make a vector implement std::io::Read and std::io::Write like:
#[test]
fn test_sql() {
let input = std::io::Cursor::new("SELECT * FROM table;".as_bytes());
let mut output = std::io::Cursor::new(vec![]);
minify_sql(input, &mut output).unwrap();
assert_eq!(
"SELECT * FROM table;",
output.into_inner().as_slice()
);
}And you could still allow reading and writing to files if passed like:
#[test]
fn test_file_sql() {
minify_sql(
std::fs::File::open("input.sql"),
&mut std::fs::File::create("output.sql"),
).unwrap();
}Metadata
Metadata
Assignees
Labels
No labels