shrupl/src/test_util/mod.rs

29 lines
618 B
Rust
Raw Normal View History

#![cfg(test)]
pub mod data;
mod mock_client;
mod mock_ids;
use std::{fmt, io::Write};
use tempfile::NamedTempFile;
2025-07-05 23:00:54 +00:00
pub fn check_trait<A, E>(actual: A, expected: E, tr: &str, ty: &str)
where
2025-07-05 23:00:54 +00:00
A: fmt::Debug + PartialEq<E>,
E: fmt::Debug,
{
assert_eq!(
2025-07-05 23:00:54 +00:00
actual, expected,
"`impl {tr} for {ty}` expected: {:?}, actual: {:?}",
expected, actual,
);
}
/// Helper to create a temp file from `data`
pub fn create_file(data: &[u8]) -> NamedTempFile {
let mut tmp = NamedTempFile::new().expect("creating temp file");
tmp.write_all(data).expect("writing to tempfile");
tmp
}