sonic-channel/tests/push_command.rs
Dmitriy Pleshevskiy bd08317388
Design improvements (#13)
* 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
2022-07-18 11:07:12 +00:00

60 lines
1.3 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}