-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration_test.rs
56 lines (50 loc) · 1.52 KB
/
integration_test.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#[macro_use]
extern crate lazy_static;
use buffer_trigger::{
self, buffer_trigger_async, buffer_trigger_sync, buffer_trigger_sync::BufferTrigger,
};
use log::LevelFilter;
use std::{thread, time::Duration};
use tokio::time::sleep;
lazy_static! {
static ref SIMPLE_BUFFER_TRIGGER: buffer_trigger_sync::Simple<i32, Vec<i32>> =
buffer_trigger_sync::SimpleBuilder::builder(Vec::default)
.name("test".to_owned())
.accumulator(|c, e| c.push(e))
.consumer(|c| log::info!("{:?}", c))
.max_len(15)
.interval(Duration::from_millis(500))
.build();
}
#[test]
fn simple_test() {
let _ = env_logger::builder()
.is_test(true)
.filter_level(LevelFilter::Debug)
.try_init();
for i in 0..100 {
SIMPLE_BUFFER_TRIGGER.push(i);
}
thread::sleep(Duration::from_secs(5));
}
lazy_static! {
static ref ASYNC_BUFFER_TRIGGER: buffer_trigger_async::Simple<i32, Vec<i32>> =
buffer_trigger_async::SimpleBuilder::builder(Vec::default)
.name("test".to_owned())
.accumulator(|c, e| c.push(e))
.consumer(|c| log::info!("{:?}", c))
.max_len(15)
.interval(Duration::from_millis(500))
.build();
}
#[tokio::test]
async fn async_test() {
let _ = env_logger::builder()
.is_test(true)
.filter_level(LevelFilter::Debug)
.try_init();
for i in 0..100 {
ASYNC_BUFFER_TRIGGER.push(i).await;
}
sleep(Duration::from_secs(5)).await;
}