start with a test of the interactive

This commit is contained in:
Abraham Toriz 2022-07-19 18:39:06 +08:00
parent 256f622a57
commit b53807c4a6
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
1 changed files with 25 additions and 2 deletions

View File

@ -166,9 +166,32 @@ Checked into sheet \"default\".\n");
ResumeCommand::handle(args, &mut streams, &facts).unwrap();
assert_eq!(Ps(&String::from_utf8_lossy(&streams.out)), Ps("\
assert_str_eq!(&String::from_utf8_lossy(&streams.out), "\
No entry to resume in the sheet 'default'. Perhaps start a new one?
Hint: use t in
"));
");
}
#[test]
fn resume_interactive() {
let args = Args {
entry: SelectedEntry::Interactive,
at: None,
};
let mut streams = Streams::fake(b"1\n");
let facts = Facts::new();
let one_hour_ago = facts.now - Duration::hours(1);
let two_hours_ago = facts.now - Duration::hours(2);
// insert some entries to pick from
streams.db.entry_insert(two_hours_ago, Some(one_hour_ago), Some("fake note".into()), "default").unwrap();
// call the command interactively
ResumeCommand::handle(args, &mut streams, &facts).unwrap();
// check the output
assert_str_eq!(&String::from_utf8_lossy(&streams.out), "Resuming \"fake note\"
Checked into sheet \"default\".\n");
assert_str_eq!(&String::from_utf8_lossy(&streams.err), "");
}
}