tests(integration): add suggest command
This commit is contained in:
parent
b36d34a870
commit
e8ec20e82f
2 changed files with 40 additions and 0 deletions
|
@ -13,6 +13,14 @@ pub fn search_start() -> SearchChannel {
|
||||||
SearchChannel::start(HOST, PASS).expect("The Sonic server must be running")
|
SearchChannel::start(HOST, PASS).expect("The Sonic server must be running")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn control_start() -> ControlChannel {
|
||||||
|
ControlChannel::start(HOST, PASS).expect("The Sonic server must be running")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn consolidate() {
|
||||||
|
control_start().consolidate().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn flush_bucket(collection: &str, bucket: &str) {
|
pub fn flush_bucket(collection: &str, bucket: &str) {
|
||||||
ingest_start().flushb(collection, bucket).unwrap();
|
ingest_start().flushb(collection, bucket).unwrap();
|
||||||
}
|
}
|
||||||
|
|
32
tests/suggest_command.rs
Normal file
32
tests/suggest_command.rs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
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 ingest_channel = ingest_start();
|
||||||
|
ingest_channel.push(COLLECTION, bucket, "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(COLLECTION, bucket, input) {
|
||||||
|
Ok(object_ids) => assert_eq!(object_ids, vec![expected]),
|
||||||
|
Err(_) => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flush_bucket(COLLECTION, bucket);
|
||||||
|
}
|
Loading…
Reference in a new issue