Fix tests

This commit is contained in:
Savanni D'Gerinel 2023-12-27 21:07:16 -05:00
parent ddb72d71d4
commit 434815ef43
1 changed files with 47 additions and 27 deletions

View File

@ -172,39 +172,59 @@ impl From<Vec<Record<TraxRecord>>> for GroupedRecords {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::GroupedRecords; use super::GroupedRecords;
use chrono::{NaiveDate, TimeZone}; use chrono::{FixedOffset, NaiveDate, TimeZone};
use chrono_tz::America::Anchorage;
use dimensioned::si::{KG, M, S}; use dimensioned::si::{KG, M, S};
use emseries::DateTimeTz; use emseries::{Record, RecordId};
use ft_core::{Steps, TimeDistance, TraxRecord, Weight}; use ft_core::{Steps, TimeDistance, TraxRecord, Weight};
#[test] #[test]
fn groups_records() { fn groups_records() {
let records = vec![ let records = vec![
TraxRecord::Steps(Steps { Record {
date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(), id: RecordId::default(),
count: 1500, data: TraxRecord::Steps(Steps {
}), date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(),
TraxRecord::Weight(Weight { count: 1500,
date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(), }),
weight: 85. * KG, },
}), Record {
TraxRecord::Weight(Weight { id: RecordId::default(),
date: NaiveDate::from_ymd_opt(2023, 10, 14).unwrap(), data: TraxRecord::Weight(Weight {
weight: 86. * KG, date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(),
}), weight: 85. * KG,
TraxRecord::BikeRide(TimeDistance { }),
datetime: DateTimeTz(Anchorage.with_ymd_and_hms(2019, 6, 15, 12, 0, 0).unwrap()), },
distance: Some(1000. * M), Record {
duration: Some(150. * S), id: RecordId::default(),
comments: Some("Test Comments".to_owned()), data: TraxRecord::Weight(Weight {
}), date: NaiveDate::from_ymd_opt(2023, 10, 14).unwrap(),
TraxRecord::BikeRide(TimeDistance { weight: 86. * KG,
datetime: DateTimeTz(Anchorage.with_ymd_and_hms(2019, 6, 15, 23, 0, 0).unwrap()), }),
distance: Some(1000. * M), },
duration: Some(150. * S), Record {
comments: Some("Test Comments".to_owned()), id: RecordId::default(),
}), data: TraxRecord::BikeRide(TimeDistance {
datetime: FixedOffset::west_opt(10 * 60 * 60)
.unwrap()
.with_ymd_and_hms(2019, 6, 15, 12, 0, 0)
.unwrap(),
distance: Some(1000. * M),
duration: Some(150. * S),
comments: Some("Test Comments".to_owned()),
}),
},
Record {
id: RecordId::default(),
data: TraxRecord::BikeRide(TimeDistance {
datetime: FixedOffset::west_opt(10 * 60 * 60)
.unwrap()
.with_ymd_and_hms(2019, 6, 15, 23, 0, 0)
.unwrap(),
distance: Some(1000. * M),
duration: Some(150. * S),
comments: Some("Test Comments".to_owned()),
}),
},
]; ];
let groups = GroupedRecords::from(records).0; let groups = GroupedRecords::from(records).0;