mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
28 lines
751 B
Rust
28 lines
751 B
Rust
use taskchampion::Replica;
|
|
use termcolor::WriteColor;
|
|
|
|
pub(crate) fn execute<W: WriteColor>(w: &mut W, replica: &mut Replica) -> Result<(), crate::Error> {
|
|
if replica.undo()? {
|
|
writeln!(w, "Undo successful.")?;
|
|
} else {
|
|
writeln!(w, "Nothing to undo.")?;
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test {
|
|
use super::*;
|
|
use crate::invocation::test::*;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn test_undo() {
|
|
let mut w = test_writer();
|
|
let mut replica = test_replica();
|
|
|
|
// Note that the details of the actual undo operation are tested thoroughly in the taskchampion crate
|
|
execute(&mut w, &mut replica).unwrap();
|
|
assert_eq!(&w.into_string(), "Nothing to undo.\n")
|
|
}
|
|
}
|