feat: voice_note field in entry frontmatter
This commit is contained in:
parent
ca9eaf0662
commit
d66e004b0d
3 changed files with 44 additions and 0 deletions
|
|
@ -17,6 +17,8 @@ pub struct EntryMeta {
|
||||||
pub website: String,
|
pub website: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub drawing: String,
|
pub drawing: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub voice_note: String,
|
||||||
pub status: Status,
|
pub status: Status,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,4 +227,44 @@ Hello!"#;
|
||||||
let reparsed = Entry::parse("test", &serialized).unwrap();
|
let reparsed = Entry::parse("test", &serialized).unwrap();
|
||||||
assert_eq!(reparsed.meta.drawing, "abc123.png");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ mod tests {
|
||||||
date: date.into(),
|
date: date.into(),
|
||||||
website: String::new(),
|
website: String::new(),
|
||||||
drawing: String::new(),
|
drawing: String::new(),
|
||||||
|
voice_note: String::new(),
|
||||||
status: Status::Approved,
|
status: Status::Approved,
|
||||||
},
|
},
|
||||||
body: body.into(),
|
body: body.into(),
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,7 @@ async fn submit(
|
||||||
date,
|
date,
|
||||||
website,
|
website,
|
||||||
drawing: drawing_filename,
|
drawing: drawing_filename,
|
||||||
|
voice_note: String::new(),
|
||||||
status: Status::Pending,
|
status: Status::Pending,
|
||||||
},
|
},
|
||||||
body: message,
|
body: message,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue