fix: Add test for coverage

This commit is contained in:
Alex Wellnitz 2023-10-25 22:59:15 +02:00
parent 413ec2a160
commit fe3d2b7d29

View File

@ -1,6 +1,6 @@
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use rustysearch::{types::Stats, search::Rustysearch}; use rustysearch::{search::Rustysearch, types::Stats};
#[test] #[test]
fn test_write_new_stats() { fn test_write_new_stats() {
@ -93,7 +93,10 @@ mod tests {
search.setup(); search.setup();
let segment_name = search.make_segment_name("hello"); let segment_name = search.make_segment_name("hello");
assert_eq!(segment_name, "/tmp/rustysearch_makesegmentname/index/5d4140.index"); assert_eq!(
segment_name,
"/tmp/rustysearch_makesegmentname/index/5d4140.index"
);
} }
#[test] #[test]
@ -108,6 +111,13 @@ mod tests {
assert_eq!(info, "{\"frequency\": 100}"); assert_eq!(info, "{\"frequency\": 100}");
} }
#[test]
fn test_make_tokens() {
let search = Rustysearch::new("/tmp/rustysearch");
let tokens = search.make_tokens("Hello, world!");
assert_eq!(tokens, vec!["hello", "world"]);
}
// Helper function to clean up the stats file // Helper function to clean up the stats file
fn clean_stats(tmp_path: &str) { fn clean_stats(tmp_path: &str) {
let search = Rustysearch::new(tmp_path); let search = Rustysearch::new(tmp_path);