Dmitriy Pleshevskiy
bd08317388
* protocol: extract response type * deps: drop lazy_static and regex * protocol: extract request commands * protocol: create a struct for... ...formatting and parsing sonic protocol * protocol: refac flush command * commands: introduce dest, refac push and count * commands: refac all commands * commands: add convinient methods * doc: add documentation for each new structs * doc: change examples in the readme * commands: implement from trait for count and flush * commands: change pag logic
36 lines
872 B
Rust
36 lines
872 B
Rust
mod common;
|
|
use common::*;
|
|
|
|
const COLLECTION: &str = "Search";
|
|
|
|
#[test]
|
|
fn should_suggest_nearest_word() {
|
|
let bucket = "suggest_nearest";
|
|
let title = "Sweet Teriyaki Beef Skewers";
|
|
|
|
let dest = Dest::col_buc(COLLECTION, bucket);
|
|
|
|
let ingest_channel = ingest_start();
|
|
ingest_channel
|
|
.push(PushRequest::new(dest.clone().obj("1"), title))
|
|
.unwrap();
|
|
|
|
consolidate();
|
|
|
|
let pairs = [
|
|
("Sweat", "sweet"),
|
|
("teriaki", "teriyaki"),
|
|
("Beff", "beef"),
|
|
("skwers", "skewers"),
|
|
];
|
|
|
|
let search_channel = search_start();
|
|
for (input, expected) in pairs {
|
|
match search_channel.suggest(SuggestRequest::new(dest.clone(), input)) {
|
|
Ok(object_ids) => assert_eq!(object_ids, vec![expected]),
|
|
Err(_) => unreachable!(),
|
|
}
|
|
}
|
|
|
|
flush_bucket(COLLECTION, bucket);
|
|
}
|