From dd3b47fcd432a6d4d714a9a8d8ef4add22305b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 11 Sep 2024 10:04:37 +0300 Subject: [PATCH] fix(test): update test cases --- src/app.rs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/app.rs b/src/app.rs index 1bcf9f9..de15f82 100644 --- a/src/app.rs +++ b/src/app.rs @@ -91,30 +91,40 @@ mod tests { use super::*; use std::{fs, path::PathBuf}; - fn get_test_bytes() -> Result> { - let debug_binary = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + fn get_test_path() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("target") .join("debug") - .join(env!("CARGO_PKG_NAME")); + .join(env!("CARGO_PKG_NAME")) + } + + fn get_test_bytes() -> Result> { + let debug_binary = get_test_path(); Ok(fs::read(debug_binary)?) } #[test] fn test_init() -> Result<()> { - assert!(Analyzer::new( - FileInfo::new("Cargo.toml", get_test_bytes()?.as_slice())?, + Analyzer::new( + FileInfo::new( + get_test_path().to_str().expect("failed to get test path"), + get_test_bytes()?.as_slice(), + )?, 4, - vec![] + vec![], ) - .is_ok()); - Ok(()) + .map(|_| ()) } #[test] fn test_extract_strings() -> Result<()> { let test_bytes = get_test_bytes()?; + let test_path = get_test_path(); let mut analyzer = Analyzer::new( - FileInfo::new("Cargo.toml", test_bytes.as_slice())?, + FileInfo::new( + test_path.to_str().expect("failed to get test path"), + test_bytes.as_slice(), + )?, 4, vec![], )?;