Skip to content

Commit

Permalink
Increasing coverage + Adding another rollback()
Browse files Browse the repository at this point in the history
The rollback functions really are just to help the code be descriptive.
Using it versus dropping is completely optional.``
  • Loading branch information
ecton committed Mar 1, 2022
1 parent 55ce6f9 commit d691646
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions nebari/src/roots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,13 @@ impl<File: ManagedFile> ExecutingTransaction<File> {
Ok(())
}

/// Rolls the transaction back. It is not necessary to call this function --
/// transactions will automatically be rolled back when the transaction is
/// dropped, if `commit()` isn't called first.
pub fn rollback(self) {
drop(self);
}

/// Accesses a locked tree.
pub fn tree<Root: tree::Root>(
&self,
Expand Down Expand Up @@ -1308,7 +1315,7 @@ mod tests {
.unwrap();

// Roll the transaction back
drop(transaction);
transaction.rollback();

// Ensure that the reader still sees the old value
let result = tree.get(b"test").unwrap().expect("key not found");
Expand Down Expand Up @@ -1497,7 +1504,7 @@ mod tests {
ErrorKind::ValueTooLarge
));
// Roll the transaction back
drop(transaction);
transaction.rollback();
}
// Ensure that we can still write to the tree.
{
Expand Down
2 changes: 1 addition & 1 deletion nebari/src/transaction/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ mod tests {
handle.commit().unwrap();
} else {
println!("Dropping handle {}", handle.id);
drop(handle);
handle.rollback();
}
}));
}
Expand Down

0 comments on commit d691646

Please sign in to comment.