shrupl/src/test_util/mod.rs
2025-07-09 15:57:43 +00:00

30 lines
681 B
Rust

#![cfg(test)]
pub mod data;
mod mock_client;
mod mock_ids;
pub use mock_client::MockClient;
use std::{fmt, io::Write};
use tempfile::NamedTempFile;
#[allow(clippy::needless_pass_by_value)]
pub fn check_trait<A, E>(actual: A, expected: E, tr: &str, ty: &str)
where
A: fmt::Debug + PartialEq<E>,
E: fmt::Debug,
{
assert_eq!(
actual, expected,
"`impl {tr} for {ty}` expected: {expected:?}, actual: {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
}