design a test for archive-by-hours

This commit is contained in:
Abraham Toriz 2022-07-25 13:09:04 +08:00
parent d18319fd33
commit 2b8cc6f94a
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
2 changed files with 26 additions and 1 deletions

View File

@ -90,3 +90,28 @@ impl<'a> Command<'a> for ArchiveCommand {
Ok(())
}
}
#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;
use super::*;
#[test]
fn archive_by_hours() {
let args = Args {
time: Some(Duration::hours(2)),
..Default::default()
};
let mut streams = Streams::fake(b"");
let facts = Facts::new();
ArchiveCommand::handle(args, &mut streams, &facts).unwrap();
let remaining = streams.db.entries_by_sheet("default", None, None).unwrap();
let archived = streams.db.entries_by_sheet("_default", None, None).unwrap();
assert_eq!(remaining, vec![]);
assert_eq!(archived, vec![]);
}
}

View File

@ -1,7 +1,7 @@
use chrono::{DateTime, Utc};
use serde::Serialize;
#[derive(Debug, Serialize)]
#[derive(Debug, PartialEq, Serialize)]
pub struct Entry {
pub id: u64,
pub note: Option<String>,