design a test for archive-by-hours
This commit is contained in:
parent
d18319fd33
commit
2b8cc6f94a
|
@ -90,3 +90,28 @@ impl<'a> Command<'a> for ArchiveCommand {
|
||||||
Ok(())
|
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![]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, PartialEq, Serialize)]
|
||||||
pub struct Entry {
|
pub struct Entry {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
pub note: Option<String>,
|
pub note: Option<String>,
|
||||||
|
|
Loading…
Reference in New Issue