test display with old databases
This commit is contained in:
parent
2e06994314
commit
bd10e8582a
Binary file not shown.
|
@ -39,6 +39,7 @@ impl FromStr for Sheet {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Args {
|
||||
ids: bool,
|
||||
start: Option<DateTime<Utc>>,
|
||||
|
@ -96,3 +97,41 @@ impl<'a> Command<'a> for DisplayCommand {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use crate::database::SqliteDatabase;
|
||||
use crate::test_utils::PrettyString;
|
||||
|
||||
#[test]
|
||||
fn display_as_local_time_if_previous_version() {
|
||||
let args = Default::default();
|
||||
let mut db = SqliteDatabase::from_path("assets/test_old_db.db").unwrap();
|
||||
let mut out = Vec::new();
|
||||
let mut err = Vec::new();
|
||||
let config = Default::default();
|
||||
|
||||
DisplayCommand::handle(args, &mut db, &mut out, &mut err, &config).unwrap();
|
||||
|
||||
assert_eq!(PrettyString(&String::from_utf8_lossy(&out)), PrettyString("Timesheet: default
|
||||
Day Start End Duration Notes
|
||||
Tue Jun 29, 2021 06:26:49 - 07:26:52 1:00:03 lets do some rust
|
||||
1:00:03
|
||||
---------------------------------------------------------------------
|
||||
Total 1:00:03
|
||||
"));
|
||||
|
||||
assert_eq!(
|
||||
PrettyString(&String::from_utf8_lossy(&err)),
|
||||
PrettyString("[WARNING] You are using the old timetrap format, it is advised that you update your database using t migrate")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn correctly_use_utc_if_new_version() {
|
||||
assert!(false, "start with a newly created database");
|
||||
assert!(false, "correctly display times in local timezone");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,12 @@ pub enum Formatter {
|
|||
Custom(String),
|
||||
}
|
||||
|
||||
impl Default for Formatter {
|
||||
fn default() -> Formatter {
|
||||
Formatter::Text
|
||||
}
|
||||
}
|
||||
|
||||
impl Formatter {
|
||||
/// Prints the given entries to the specified output device.
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue