diff --git a/src/entries.rs b/src/entries.rs index e9af7a8..4c071bf 100644 --- a/src/entries.rs +++ b/src/entries.rs @@ -17,6 +17,8 @@ pub struct EntryMeta { pub website: String, #[serde(default)] pub drawing: String, + #[serde(default)] + pub voice_note: String, pub status: Status, } @@ -225,4 +227,44 @@ Hello!"#; let reparsed = Entry::parse("test", &serialized).unwrap(); assert_eq!(reparsed.meta.drawing, "abc123.png"); } + + #[test] + fn test_parse_entry_with_voice_note() { + let contents = r#"+++ +name = "alice" +date = "2026-04-10" +status = "approved" +voice_note = "1744300800_abcd1234.webm" ++++ +Hello!"#; + let entry = Entry::parse("test", contents).unwrap(); + assert_eq!(entry.meta.voice_note, "1744300800_abcd1234.webm"); + } + + #[test] + fn test_parse_entry_without_voice_note() { + let contents = r#"+++ +name = "bob" +date = "2026-04-10" +status = "pending" ++++ +Hi!"#; + let entry = Entry::parse("test", contents).unwrap(); + assert_eq!(entry.meta.voice_note, ""); + } + + #[test] + fn test_roundtrip_with_voice_note() { + let contents = r#"+++ +name = "alice" +date = "2026-04-10" +status = "approved" +voice_note = "1744300800_abcd1234.webm" ++++ +Hello!"#; + let entry = Entry::parse("test", contents).unwrap(); + let serialized = entry.to_file_contents(); + let reparsed = Entry::parse("test", &serialized).unwrap(); + assert_eq!(reparsed.meta.voice_note, "1744300800_abcd1234.webm"); + } } diff --git a/src/render.rs b/src/render.rs index 440d7ca..44ee119 100644 --- a/src/render.rs +++ b/src/render.rs @@ -262,6 +262,7 @@ mod tests { date: date.into(), website: String::new(), drawing: String::new(), + voice_note: String::new(), status: Status::Approved, }, body: body.into(), diff --git a/src/web.rs b/src/web.rs index e8e2bb7..f673b82 100644 --- a/src/web.rs +++ b/src/web.rs @@ -212,6 +212,7 @@ async fn submit( date, website, drawing: drawing_filename, + voice_note: String::new(), status: Status::Pending, }, body: message,