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
60 lines
1.3 KiB
Rust
60 lines
1.3 KiB
Rust
mod common;
|
||
use common::*;
|
||
|
||
const COLLECTION: &str = "Ingest";
|
||
|
||
#[test]
|
||
fn should_push_new_object_to_sonic() {
|
||
let bucket = "push_simple";
|
||
|
||
let dest = Dest::col_buc(COLLECTION, bucket);
|
||
|
||
let ingest_channel = ingest_start();
|
||
match ingest_channel.push(PushRequest::new(
|
||
dest.obj("1"),
|
||
"Sweet Teriyaki Beef Skewers",
|
||
)) {
|
||
Ok(()) => {}
|
||
_ => unreachable!(),
|
||
}
|
||
|
||
flush_bucket(COLLECTION, bucket);
|
||
}
|
||
|
||
#[test]
|
||
fn should_push_new_object_to_sonic_with_russian_locale() {
|
||
let bucket = "push_locale";
|
||
|
||
let dest = Dest::col_buc(COLLECTION, bucket);
|
||
|
||
let ingest_channel = ingest_start();
|
||
match ingest_channel.push(
|
||
PushRequest::new(dest.obj("1"), "Открытый пирог с орехами и сгущенкой").lang(Lang::Rus),
|
||
) {
|
||
Ok(()) => {}
|
||
_ => unreachable!(),
|
||
}
|
||
|
||
flush_bucket(COLLECTION, bucket);
|
||
}
|
||
|
||
#[test]
|
||
fn should_push_multiline_text() {
|
||
let bucket = "push_multiline";
|
||
let multiline_text = "
|
||
Sweet
|
||
Teriyaki
|
||
Beef
|
||
Skewers
|
||
";
|
||
|
||
let dest = Dest::col_buc(COLLECTION, bucket);
|
||
|
||
let ingest_channel = ingest_start();
|
||
match ingest_channel.push(PushRequest::new(dest.obj("1"), multiline_text)) {
|
||
Ok(()) => {}
|
||
_ => unreachable!(),
|
||
}
|
||
|
||
flush_bucket(COLLECTION, bucket);
|
||
}
|