feat: voice_note field in entry frontmatter

This commit is contained in:
Lewis Wynne 2026-04-10 02:14:57 +01:00
parent ca9eaf0662
commit d66e004b0d
3 changed files with 44 additions and 0 deletions

View file

@ -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");
}
}