use std::io::Write; use crate::models::Entry; use crate::error::Result; pub fn print_formatted(entries: Vec, out: &mut W) -> Result<()> { unimplemented!() } #[cfg(test)] mod tests { use pretty_assertions::assert_eq; use chrono::{Utc, Duration}; use crate::test_utils::PrettyString; use super::*; #[test] fn ical_format() { let now = Utc::now(); let an_hour_ago = now - Duration::hours(1); let entries = vec![ Entry::new_sample(1, an_hour_ago, Some(now)), Entry::new_sample(1, an_hour_ago, None), ]; let mut out = Vec::new(); print_formatted(entries, &mut out).unwrap(); assert_eq!(PrettyString(&String::from_utf8_lossy(&out)), PrettyString(&format!("\ BEGIN:VCALENDAR\ CALSCALE:GREGORIAN\ METHOD:PUBLISH\ PRODID:tiempo-rs\ VERSION:2.0\ BEGIN:VEVENT\ DESCRIPTION:{note}\ DTEND:{end}\ DTSTAMP:{now}\ DTSTART:{start}\ SEQUENCE:0\ SUMMARY:{note}\ UID:{uid}@{host}\ END:VEVENT\ END:VCALENDAR\ "))); } }