Skip to content

Commit

Permalink
chore: incorrect cursor end example
Browse files Browse the repository at this point in the history
  • Loading branch information
mnpw committed Apr 18, 2023
1 parent 484b80e commit 2504e76
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rumqttd/src/segments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,17 @@ mod tests {

// Read one by one
let mut out = Vec::new();
let mut last_read_cursor = (0, 0);
for i in 0..10 {
let offset = i as u64;
let next = log.readv((0, offset), 1, &mut out).unwrap();
let data = out.pop().unwrap();
verify(i, packet_size, data);

if i == 9 {
if let Done { start: _, end } = next {
last_read_cursor = end;
};
assert_eq!(
next,
Done {
Expand All @@ -404,6 +408,11 @@ mod tests {
);
}

log.append(random_payload(10, packet_size));
log.readv(last_read_cursor, 1, &mut out).unwrap();
let data = out.pop().unwrap();
verify(10, packet_size, data);

// Read in bulk 1. Trying to read less than appended
let mut out = Vec::new();
let next = log.readv((0, 0), 5, &mut out).unwrap();
Expand Down

0 comments on commit 2504e76

Please sign in to comment.