feat: add unit tests for handler_hello and search_engine

This commit is contained in:
Alex Wellnitz 2024-02-11 17:10:02 +01:00
parent c4f50af39a
commit 5b7f3d802d
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,10 @@
#[cfg(test)]
mod tests {
use rustysearch::handler::hello::say_hello;
#[tokio::test]
async fn test_say_hello() {
let result = say_hello().await;
assert_eq!(result, "Hello, World!");
}
}

View File

@ -0,0 +1,14 @@
#[cfg(test)]
mod tests {
use rustysearch::search::engine::SearchEngine;
#[test]
fn test_search_engine() {
let mut search_engine = SearchEngine::new(1.2, 0.75);
search_engine.index("https://www.rust-lang.org/", "Rust Programming Language");
assert_eq!(search_engine.posts().len(), 1);
assert_eq!(search_engine.number_of_documents(), 1);
}
}