2021-04-21 13:09:13 +00:00
|
|
|
use write_buffer::{WriteBufferBuilder, WritePayload};
|
2020-05-11 19:09:10 +00:00
|
|
|
|
|
|
|
#[test]
|
2021-04-05 18:41:02 +00:00
|
|
|
fn no_concurrency() {
|
|
|
|
let dir = test_helpers::tmp_dir().unwrap();
|
2021-04-21 13:09:13 +00:00
|
|
|
let builder = WriteBufferBuilder::new(dir.as_ref());
|
|
|
|
let mut write_buffer = builder.clone().write_buffer().unwrap();
|
2020-05-11 19:09:10 +00:00
|
|
|
|
2020-09-08 18:12:16 +00:00
|
|
|
let data = Vec::from("somedata");
|
2021-04-05 18:41:02 +00:00
|
|
|
let payload = WritePayload::new(data).unwrap();
|
2021-04-21 13:09:13 +00:00
|
|
|
let sequence_number = write_buffer.append(payload).unwrap();
|
|
|
|
write_buffer.sync_all().unwrap();
|
2020-05-11 19:09:10 +00:00
|
|
|
|
2020-09-08 18:12:16 +00:00
|
|
|
assert_eq!(0, sequence_number);
|
2020-05-11 19:09:10 +00:00
|
|
|
|
2021-04-21 13:09:13 +00:00
|
|
|
let write_buffer_entries: Result<Vec<_>, _> = builder.entries().unwrap().collect();
|
|
|
|
let write_buffer_entries = write_buffer_entries.unwrap();
|
|
|
|
assert_eq!(1, write_buffer_entries.len());
|
|
|
|
assert_eq!(b"somedata".as_ref(), write_buffer_entries[0].as_data());
|
|
|
|
assert_eq!(0, write_buffer_entries[0].sequence_number());
|
2020-05-11 19:09:10 +00:00
|
|
|
}
|