refactor: search engine and add debug index test
This commit is contained in:
parent
d510178127
commit
a75a278088
@ -38,7 +38,6 @@ fn normalize_string(input_string: &str) -> String {
|
||||
/// println!("{} - Relevance Score: {}", url, score);
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct SearchEngine {
|
||||
index: HashMap<String, HashMap<String, i32>>,
|
||||
|
@ -81,4 +81,25 @@ mod tests {
|
||||
let resp = test::call_service(&app, req).await;
|
||||
assert!(resp.status() == 200);
|
||||
}
|
||||
|
||||
#[actix_web::test]
|
||||
async fn test_debug_index() {
|
||||
let search_engine = SearchEngine::new(1.5, 0.75);
|
||||
|
||||
let app_state = web::Data::new(AppStateWithSearchEngine {
|
||||
search_engine: Mutex::new(search_engine.clone()),
|
||||
});
|
||||
|
||||
let app = test::init_service(App::new()
|
||||
.app_data(app_state.clone())
|
||||
.route("/search/debug", web::get().to(search::debug_index))
|
||||
).await;
|
||||
|
||||
let req = test::TestRequest::get()
|
||||
.uri("/search/debug")
|
||||
.to_request();
|
||||
|
||||
let resp = test::call_service(&app, req).await;
|
||||
assert!(resp.status() == 200);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user