feat: add unit tests for handler_hello and search_engine
This commit is contained in:
parent
c4f50af39a
commit
5b7f3d802d
10
tests/handler_hello_test.rs
Normal file
10
tests/handler_hello_test.rs
Normal 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!");
|
||||
}
|
||||
}
|
14
tests/search_engine_tests.rs
Normal file
14
tests/search_engine_tests.rs
Normal 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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user