2021-12-25 00:11:34 +03:00
|
|
|
mod common;
|
|
|
|
use common::*;
|
|
|
|
|
|
|
|
const COLLECTION: &str = "Search";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn should_suggest_nearest_word() {
|
|
|
|
let bucket = "suggest_nearest";
|
|
|
|
let title = "Sweet Teriyaki Beef Skewers";
|
|
|
|
|
2022-07-18 14:07:12 +03:00
|
|
|
let dest = Dest::col_buc(COLLECTION, bucket);
|
|
|
|
|
2021-12-25 00:11:34 +03:00
|
|
|
let ingest_channel = ingest_start();
|
2022-07-18 14:07:12 +03:00
|
|
|
ingest_channel
|
|
|
|
.push(PushRequest::new(dest.clone().obj("1"), title))
|
|
|
|
.unwrap();
|
2021-12-25 00:11:34 +03:00
|
|
|
|
|
|
|
consolidate();
|
|
|
|
|
|
|
|
let pairs = [
|
|
|
|
("Sweat", "sweet"),
|
|
|
|
("teriaki", "teriyaki"),
|
|
|
|
("Beff", "beef"),
|
|
|
|
("skwers", "skewers"),
|
|
|
|
];
|
|
|
|
|
|
|
|
let search_channel = search_start();
|
|
|
|
for (input, expected) in pairs {
|
2022-07-18 14:07:12 +03:00
|
|
|
match search_channel.suggest(SuggestRequest::new(dest.clone(), input)) {
|
2021-12-25 00:11:34 +03:00
|
|
|
Ok(object_ids) => assert_eq!(object_ids, vec![expected]),
|
|
|
|
Err(_) => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flush_bucket(COLLECTION, bucket);
|
|
|
|
}
|