776 lines · 27.1 KB · RustRaw
//! Ported case-for-case from `packages/import-core/__tests__/mediaPlan.test.ts`,//! plus vector tables read out of Node (`npx tsx` over the TypeScript itself)//! for every function whose output is a string.//!//! Two properties are worth pinning here and nowhere else://!//! THE LIMITS ARE THE CALLER'S. The import core took its ceiling and its//! content-type allowlist as an argument rather than importing them, because//! the TypeScript package it was ported from had to run unchanged inside//! Hermes. The shape outlived the reason and is worth keeping: the same//! archive classifies differently under different rules.//!//! WHAT LANDS ON A MESSAGE IS A KEY. Never a url. There is one attach//! function now; the url-shaped twin went with the retired Tinmen worker.//!//! Every fixture is SYNTHETIC — invented numbers, invented names, invented//! words. Nothing from anybody's real chat history goes in this tree.use super::*;use crate::import::envelope::{Direction, EnvelopeCounterpart, EnvelopeMessage};use crate::import::normalize::ChatReport;/// A caller with the server's shape: 100 MB, and chat content types.fn wide() -> MediaPlanLimits { MediaPlanLimits { max_bytes: 104_857_600.0, content_types: ["image/jpeg", "audio/opus", "video/mp4", "application/pdf"] .into_iter() .map(str::to_string) .collect(), }}/// A stricter caller: a smaller ceiling and a shorter list.fn narrow() -> MediaPlanLimits { MediaPlanLimits { max_bytes: 25.0 * 1024.0 * 1024.0, content_types: ["image/jpeg", "video/mp4"] .into_iter() .map(str::to_string) .collect(), }}fn manifest(filename: &str, external_id: &str) -> MediaManifestEntry { MediaManifestEntry { phone: Some("919876543210".to_string()), external_id: Some(external_id.to_string()), sent_at: "2026-08-16T04:00:00.000Z".to_string(), filename: Some(filename.to_string()), mime: None, source_path: Some(filename.to_string()), omitted: false, }}fn omitted_manifest(filename: Option<&str>, external_id: Option<&str>) -> MediaManifestEntry { MediaManifestEntry { phone: Some("919876543210".to_string()), external_id: external_id.map(str::to_string), sent_at: "2026-08-16T04:00:00.000Z".to_string(), filename: filename.map(str::to_string), mime: None, source_path: filename.map(str::to_string), omitted: true, }}fn source(name: &str, size: f64) -> SourceMediaEntry { SourceMediaEntry { name: name.to_string(), size, }}fn empty_chat_report() -> ChatReport { ChatReport { kind: None, title: None, participants: None, system_imported: None, phone: Some("919876543210".to_string()), display_name: None, messages: 1, inbound: 1, outbound: 0, first_sent_at: None, last_sent_at: None, reply_refs: 0, unresolved_reply_refs: 0, reactions: 0, attachments: 0, omitted_media: 0, system_skipped: 0, album_containers_dropped: 0, warnings: Vec::new(), }}fn chat_with(body: &str, external_id: &str) -> Vec<NormalizedChat> { vec![NormalizedChat { kind: "dm".to_string(), phone: Some("919876543210".to_string()), display_name: Some("Asha".to_string()), title: None, external_key: None, counterpart: Some(EnvelopeCounterpart { label: "Asha".to_string(), email: None, phone: Some("919876543210".to_string()), person_id: None, handle: None, }), participants: Vec::new(), messages: vec![EnvelopeMessage { phone: None, email: None, sender_label: None, display_name: None, direction: Direction::In, body: body.to_string(), media: None, sent_at: "2026-08-16T04:00:00.000Z".to_string(), external_id: external_id.to_string(), reply_to_external_id: None, reactions: None, meta: None, }], report: empty_chat_report(), }]}fn photo_result() -> MediaStoredResult { MediaStoredResult { filename: "00000001-PHOTO.jpg".to_string(), external_id: Some("txt2:photo".to_string()), key: "ws-1/messages/t1/deadbeef.jpg".to_string(), content_type: "image/jpeg".to_string(), size_bytes: 2048.0, contact: None, }}/* ── planMediaUploads — limits are the caller's ──────────────────────────── *//// Keeps a type the wide caller lists and refuses it for the narrow one.#[test]fn keeps_a_type_the_wide_caller_lists_and_refuses_it_for_the_narrow_one() { let media = [manifest("00000002-AUDIO.opus", "txt2:voice")]; let entries = [source("00000002-AUDIO.opus", 40_000.0)]; let wide_plan = plan_media_uploads(&media, &entries, &wide()); assert_eq!(wide_plan.entries[0].status, MediaUploadStatus::Uploadable); assert_eq!( wide_plan.entries[0].content_type.as_deref(), Some("audio/opus") ); let narrow_plan = plan_media_uploads(&media, &entries, &narrow()); assert_eq!( narrow_plan.entries[0].status, MediaUploadStatus::UnsupportedType ); assert_eq!(narrow_plan.entries[0].content_type, None);}/// Uses the caller's byte ceiling, not one baked into the planner.#[test]fn uses_the_callers_byte_ceiling_not_one_baked_into_the_planner() { let media = [manifest("00000004-VIDEO.mp4", "txt2:vid")]; let just_over_narrow = [source("00000004-VIDEO.mp4", narrow().max_bytes + 1.0)]; assert_eq!( plan_media_uploads(&media, &just_over_narrow, &wide()).entries[0].status, MediaUploadStatus::Uploadable ); assert_eq!( plan_media_uploads(&media, &just_over_narrow, &narrow()).entries[0].status, MediaUploadStatus::Oversize ); assert_eq!( plan_media_uploads( &media, &[source("00000004-VIDEO.mp4", wide().max_bytes + 1.0)], &wide() ) .entries[0] .status, MediaUploadStatus::Oversize );}/// Exactly AT the ceiling still uploads — the TypeScript's test is `>`, so the/// boundary belongs in the port too.#[test]fn a_file_exactly_at_the_ceiling_still_uploads() { let media = [manifest("00000004-VIDEO.mp4", "txt2:vid")]; let at_the_line = [source("00000004-VIDEO.mp4", narrow().max_bytes)]; assert_eq!( plan_media_uploads(&media, &at_the_line, &narrow()).entries[0].status, MediaUploadStatus::Uploadable );}/// Counts a file the archive does not hold as missing, not as a refusal.#[test]fn counts_a_file_the_archive_does_not_hold_as_missing_not_as_a_refusal() { let plan = plan_media_uploads(&[manifest("gone.jpg", "txt2:gone")], &[], &wide()); assert_eq!(plan.counts.missing, 1); assert_eq!(plan.counts.uploadable, 0); assert_eq!(plan.counts.unsupported_type, 0); assert_eq!(plan.entries[0].status, MediaUploadStatus::Missing); assert_eq!(plan.entries[0].size_bytes, None);}/* ── extensionOf ────────────────────────────────────────────────────────── *//// Answers the lowercase extension of the last path segment.#[test]fn extension_of_answers_the_lowercase_extension_of_the_last_path_segment() { assert_eq!(extension_of("Folder/00000001-PHOTO.JPG"), "jpg"); assert_eq!(extension_of("noext"), "");}/// Node vectors (14) — `npx tsx` over `mediaPlan.ts`, values pasted verbatim.#[test]fn extension_of_matches_node() { let vectors: [(&str, &str); 14] = [ ("Folder/00000001-PHOTO.JPG", "jpg"), ("noext", ""), ("", ""), (".", ""), (".gitignore", "gitignore"), ("a/b/c/AUDIO.OPUS", "opus"), ("trailing.", ""), ("two.dots.tar.GZ", "gz"), ("dir.with.dot/file", ""), ("00000002-AUDIO.opus", "opus"), ("IMG_0001.HEIC", "heic"), ("Sheet.XLSX", "xlsx"), ("weird/na me.PdF", "pdf"), ("/leading/slash.mp4", "mp4"), ]; for (input, expected) in vectors { assert_eq!(extension_of(input), expected, "extensionOf({input:?})"); }}/* ── displayNameFor ─────────────────────────────────────────────────────── *//// Node vectors (12). `"123-"` reads as an all-counter name and empties, and/// `"00-wide.jpg"` proves the port kept JavaScript's ASCII `\d` — a/// full-width digit is not an export counter on either side.#[test]fn display_name_for_matches_node() { let vectors: [(&str, &str); 12] = [ ("00003011-Requirement.docx", "Requirement.docx"), ("00000001-PHOTO.jpg", "PHOTO.jpg"), ("Folder/00000009-Anita.vcf", "Anita.vcf"), ("no-counter.jpg", "no-counter.jpg"), ("123", "123"), ("123-", ""), ("-leading.jpg", "-leading.jpg"), ("12ab-name.png", "12ab-name.png"), ("dir/0-x.mp3", "x.mp3"), ("\u{ff10}\u{ff10}-wide.jpg", "\u{ff10}\u{ff10}-wide.jpg"), ("", ""), ( "Media/919000000001@s.whatsapp.net/1/0/PHOTO.jpg", "PHOTO.jpg", ), ]; for (input, expected) in vectors { assert_eq!( display_name_for(input), expected, "displayNameFor({input:?})" ); }}/* ── contentTypeForExtension ────────────────────────────────────────────── *//// Node vectors (33) — the whole table, plus three case foldings and three/// extensions it has never heard of.#[test]fn content_type_for_extension_matches_node() { let vectors: [(&str, Option<&str>); 33] = [ ("jpg", Some("image/jpeg")), ("JPG", Some("image/jpeg")), ("jpeg", Some("image/jpeg")), ("png", Some("image/png")), ("webp", Some("image/webp")), ("heic", Some("image/heic")), ("heif", Some("image/heif")), ("gif", Some("image/gif")), ("m4a", Some("audio/m4a")), ("ogg", Some("audio/ogg")), ("opus", Some("audio/opus")), ("mov", Some("video/quicktime")), ("3gp", Some("video/3gpp")), ("mp3", Some("audio/mpeg")), ("aac", Some("audio/aac")), ("mp4", Some("video/mp4")), ("pdf", Some("application/pdf")), ("xls", Some("application/vnd.ms-excel")), ( "xlsx", Some("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), ), ( "docx", Some("application/vnd.openxmlformats-officedocument.wordprocessingml.document"), ), ("zip", Some("application/zip")), ("html", Some("text/html")), ("doc", Some("application/msword")), ("ppt", Some("application/vnd.ms-powerpoint")), ( "pptx", Some("application/vnd.openxmlformats-officedocument.presentationml.presentation"), ), ("txt", Some("text/plain")), ("csv", Some("text/csv")), ("vcf", Some("text/vcard")), ("", None), ("tiff", None), ("OPUS", Some("audio/opus")), ("Mp4", Some("video/mp4")), ("exe", None), ]; for (input, expected) in vectors { assert_eq!( content_type_for_extension(input), expected, "contentTypeForExtension({input:?})" ); }}/* ── whole-plan Node goldens ────────────────────────────────────────────── *//// A macOS screenshot is literally named with a NARROW NO-BREAK SPACE before/// "AM". The transcript is space-normalized before parsing and the archive/// entry is not, so without `matchKey` this file is `missing` — invisibly.#[test]fn plan_matches_a_reference_that_differs_by_a_narrow_no_break_space() { let plan = plan_media_uploads( &[manifest( "Screenshot 2026-08-16 at 9.41.02 AM.png", "txt2:a", )], &[source( "Screenshot 2026-08-16 at 9.41.02\u{202f}AM.png", 100.0, )], &MediaPlanLimits { max_bytes: 1000.0, content_types: vec!["image/png".to_string()], }, ); // Node golden: the entry keeps the ARCHIVE's name, NNBSP and all. assert_eq!( plan.entries[0].filename, "Screenshot 2026-08-16 at 9.41.02\u{202f}AM.png" ); assert_eq!(plan.entries[0].status, MediaUploadStatus::Uploadable); assert_eq!(plan.entries[0].content_type.as_deref(), Some("image/png")); assert_eq!(plan.counts.uploadable, 1);}/// macOS also likes decomposed accents in filenames — NFC on top of the space/// fold is what makes `Café.jpg` (composed, in the transcript) find/// `Café.jpg` (decomposed, in the archive).#[test]fn plan_matches_a_decomposed_accent_against_a_composed_reference() { let plan = plan_media_uploads( &[manifest("Caf\u{e9}.jpg", "txt2:b")], &[source("Cafe\u{301}.jpg", 10.0)], &wide(), ); assert_eq!(plan.entries[0].status, MediaUploadStatus::Uploadable); assert_eq!(plan.entries[0].filename, "Cafe\u{301}.jpg"); assert_eq!(plan.counts.uploadable, 1);}/// The base-name fallback: a zip entry that carries the export folder in front/// of it still answers a bare reference, and vice versa.#[test]fn plan_falls_back_to_the_last_path_segment() { let plan = plan_media_uploads( &[manifest("Media/deep/PHOTO.jpg", "txt2:c")], &[source("PHOTO.jpg", 10.0)], &wide(), ); assert_eq!(plan.entries[0].status, MediaUploadStatus::Uploadable); assert_eq!(plan.entries[0].filename, "PHOTO.jpg");}/// A whole five-entry plan, read out of Node: one of every status, in order.#[test]fn plan_mixed_matches_node() { let plan = plan_media_uploads( &[ manifest("00000002-AUDIO.opus", "txt2:voice"), manifest("00000004-VIDEO.mp4", "txt2:vid"), manifest("gone.jpg", "txt2:gone"), omitted_manifest(None, Some("txt2:omitted")), manifest("notes.tiff", "txt2:weird"), ], &[ source("00000002-AUDIO.opus", 40_000.0), source("00000004-VIDEO.mp4", 26_214_401.0), source("notes.tiff", 5.0), ], &wide(), ); let seen: Vec<(&str, MediaUploadStatus, Option<&str>, Option<f64>)> = plan .entries .iter() .map(|entry| { ( entry.filename.as_str(), entry.status, entry.content_type.as_deref(), entry.size_bytes, ) }) .collect(); assert_eq!( seen, vec![ ( "00000002-AUDIO.opus", MediaUploadStatus::Uploadable, Some("audio/opus"), Some(40_000.0) ), ( "00000004-VIDEO.mp4", MediaUploadStatus::Uploadable, Some("video/mp4"), Some(26_214_401.0) ), ("gone.jpg", MediaUploadStatus::Missing, None, None), ("(omitted)", MediaUploadStatus::Omitted, None, None), ( "notes.tiff", MediaUploadStatus::UnsupportedType, None, Some(5.0) ), ] ); assert_eq!( plan.counts, MediaUploadCounts { uploadable: 2, unsupported_type: 1, oversize: 0, missing: 1, omitted: 1, } );}/// The same two files under the narrow caller — Node golden. The voice note/// becomes an unsupported type and the video an oversize, and neither of those/// is a judgement this module made.#[test]fn plan_mixed_narrow_matches_node() { let plan = plan_media_uploads( &[ manifest("00000002-AUDIO.opus", "txt2:voice"), manifest("00000004-VIDEO.mp4", "txt2:vid"), ], &[ source("00000002-AUDIO.opus", 40_000.0), source("00000004-VIDEO.mp4", 26_214_401.0), ], &narrow(), ); assert_eq!( plan.entries .iter() .map(|entry| (entry.status, entry.content_type.as_deref())) .collect::<Vec<_>>(), vec![ (MediaUploadStatus::UnsupportedType, None), (MediaUploadStatus::Oversize, Some("video/mp4")), ] ); assert_eq!( plan.counts, MediaUploadCounts { uploadable: 0, unsupported_type: 1, oversize: 1, missing: 0, omitted: 0, } );}/// An entry the export marked omitted is omitted EVEN WHEN it names a file the/// archive holds — the export said the bytes are not there, and a file with/// the same name is not evidence that they are. Node golden.#[test]fn plan_omitted_wins_over_a_name_the_archive_happens_to_hold() { let plan = plan_media_uploads( &[ omitted_manifest(None, None), omitted_manifest(Some("kept.jpg"), Some("txt2:k")), ], &[source("kept.jpg", 1.0)], &wide(), ); assert_eq!( plan.entries .iter() .map(|entry| (entry.filename.as_str(), entry.status)) .collect::<Vec<_>>(), vec![ ("(omitted)", MediaUploadStatus::Omitted), ("kept.jpg", MediaUploadStatus::Omitted), ] ); assert_eq!(plan.entries[0].external_id, None); assert_eq!(plan.counts.omitted, 2);}/* ── attachStoredMedia ──────────────────────────────────────────────────── *//// Writes a KEY onto the message and clears the placeholder body.#[test]fn attach_stored_media_writes_a_key_and_clears_the_placeholder_body() { let mut chats = chat_with("[attachment: PHOTO.jpg]", "txt2:photo"); let attached = attach_stored_media(&mut chats, &[photo_result()]); assert_eq!(attached, 1); let media = chats[0].messages[0].media.clone().expect("media attached"); assert_eq!(media.len(), 1); assert_eq!( media[0].key, "ws-1/messages/t1/deadbeef.jpg" ); assert_eq!(media[0].content_type, "image/jpeg"); assert_eq!(media[0].name.as_deref(), Some("PHOTO.jpg")); assert_eq!(media[0].size_bytes, Some(2048.0)); assert_eq!(chats[0].messages[0].body, "");}/// Leaves a message nothing matched alone.#[test]fn attach_stored_media_leaves_a_message_nothing_matched_alone() { let mut chats = chat_with("[attachment: PHOTO.jpg]", "txt2:photo"); let attached = attach_stored_media( &mut chats, &[MediaStoredResult { filename: "other.jpg".to_string(), external_id: Some("txt2:somebody-else".to_string()), key: "ws-1/messages/t1/other.jpg".to_string(), content_type: "image/jpeg".to_string(), size_bytes: 1.0, contact: None, }], ); assert_eq!(attached, 0); assert_eq!(chats[0].messages[0].media, None); assert_eq!(chats[0].messages[0].body, "[attachment: PHOTO.jpg]");}/// A result no message in this import claims is dropped, not guessed at.#[test]fn attach_stored_media_drops_a_result_with_no_external_id() { let mut chats = chat_with("[attachment: PHOTO.jpg]", "txt2:photo"); let mut orphan = photo_result(); orphan.external_id = None; assert_eq!(attach_stored_media(&mut chats, &[orphan]), 0); assert_eq!(chats[0].messages[0].media, None);}/// A body that is not a placeholder survives the attach — the clearing rule is/// `startsWith("[attachment")`, not "there is media now".#[test]fn attach_stored_media_keeps_a_real_body() { let mut chats = chat_with("at the lake", "txt2:photo"); assert_eq!(attach_stored_media(&mut chats, &[photo_result()]), 1); assert_eq!(chats[0].messages[0].body, "at the lake");}/* ── attachStoredMediaIndexed ───────────────────────────────────────────── *//// Attaches exactly what `attachStoredMedia` attaches — through a prebuilt/// index.#[test]fn indexed_attach_matches_the_scanning_attach() { let stored = [photo_result()]; let mut scanned = chat_with("[attachment: PHOTO.jpg]", "txt2:photo"); let mut indexed = chat_with("[attachment: PHOTO.jpg]", "txt2:photo"); let scan_count = attach_stored_media(&mut scanned, &stored); let index = build_message_index(&indexed); let index_count = attach_stored_media_indexed(&mut indexed, &index, &stored); assert_eq!(index_count, scan_count); assert_eq!(indexed[0].messages[0], scanned[0].messages[0]);}/// Attaches repeatedly against one index without rescanning the chats.#[test]fn indexed_attach_can_run_many_times_against_one_index() { let mut chats = chat_with("[attachment: PHOTO.jpg]", "txt2:photo"); let index = build_message_index(&chats); assert_eq!(attach_stored_media_indexed(&mut chats, &index, &[]), 0); assert_eq!( attach_stored_media_indexed(&mut chats, &index, &[photo_result()]), 1 ); assert_eq!(chats[0].messages[0].body, ""); assert_eq!( chats[0].messages[0].media.as_ref().unwrap()[0].key, "ws-1/messages/t1/deadbeef.jpg" );}/// Two messages sharing one `external_id` both get the attachment, and both/// count — the index is a list per id for exactly that reason.#[test]fn indexed_attach_reaches_every_message_sharing_an_external_id() { let mut chats = chat_with("[attachment: PHOTO.jpg]", "txt2:photo"); let twin = chats[0].messages[0].clone(); chats[0].messages.push(twin); let index = build_message_index(&chats); assert_eq!( attach_stored_media_indexed(&mut chats, &index, &[photo_result()]), 2 ); assert!(chats[0].messages.iter().all(|m| m.media.is_some()));}/* ── a shared contact card ──────────────────────────────────────────────── */fn anita() -> VcardContact { VcardContact { name: "Anita Rao".to_string(), phones: vec!["+910123462001".to_string()], emails: Vec::new(), org: None, }}fn card_result(contact: Option<VcardContact>) -> MediaStoredResult { MediaStoredResult { filename: "00000009-Anita.vcf".to_string(), external_id: Some("txt2:card".to_string()), key: "ws-1/messages/t1/cafe.vcf".to_string(), content_type: "text/vcard".to_string(), size_bytes: 220.0, contact, }}/// Recognised by both spellings of the content type, and nothing else.#[test]fn is_vcard_content_type_knows_both_spellings_and_nothing_else() { assert!(is_vcard_content_type("text/vcard")); assert!(is_vcard_content_type("text/x-vcard")); assert!(is_vcard_content_type("TEXT/VCARD")); assert!(!is_vcard_content_type("text/plain")); assert!(!is_vcard_content_type("image/jpeg"));}/// Node vectors (8) — including the parametrised spelling, which is NOT one of/// the two and so is not read as a card.#[test]fn is_vcard_content_type_matches_node() { let vectors: [(&str, bool); 8] = [ ("text/vcard", true), ("text/x-vcard", true), ("TEXT/VCARD", true), ("Text/X-vCard", true), ("text/plain", false), ("image/jpeg", false), ("", false), ("text/vcard; charset=utf-8", false), ]; for (input, expected) in vectors { assert_eq!( is_vcard_content_type(input), expected, "isVcardContentType({input:?})" ); }}/// Carries the read card onto the message's media entry.#[test]fn a_read_card_rides_onto_the_media_entry() { let mut chats = chat_with("[attachment: Anita.vcf]", "txt2:card"); attach_stored_media(&mut chats, &[card_result(Some(anita()))]); let contact = chats[0].messages[0].media.as_ref().unwrap()[0] .contact .clone() .expect("the card came through"); assert_eq!( contact, serde_json::to_value(anita()).expect("a vcard contact serialises") );}/// Adds no `contact` key at all when nothing readable came out of the file.////// The bytes are still attached — a card we cannot name is a file, and the/// renderer's chip is the honest drawing of that.#[test]fn an_unreadable_card_gets_no_contact_key() { let mut chats = chat_with("[attachment: Anita.vcf]", "txt2:card"); attach_stored_media(&mut chats, &[card_result(None)]); let entry = chats[0].messages[0].media.as_ref().unwrap()[0].clone(); assert_eq!(entry.contact, None); assert_eq!(entry.key, "ws-1/messages/t1/cafe.vcf"); // `skip_serializing_if` — an absent card is an ABSENT key, not a null one, // which is the TypeScript's `not.toHaveProperty("contact")`. let json = serde_json::to_value(&entry).expect("an envelope media serialises"); assert!(json.get("contact").is_none());}/// Attaches through the index exactly as it attaches through a scan.#[test]fn a_card_attaches_the_same_way_through_the_index() { let stored = [card_result(Some(anita()))]; let mut scanned = chat_with("[attachment: Anita.vcf]", "txt2:card"); let mut indexed = chat_with("[attachment: Anita.vcf]", "txt2:card"); attach_stored_media(&mut scanned, &stored); let index = build_message_index(&indexed); attach_stored_media_indexed(&mut indexed, &index, &stored); assert_eq!(indexed[0].messages[0], scanned[0].messages[0]);}/* ── the failure shape ──────────────────────────────────────────────────── *//// `MediaUploadFailure` is the caller's vocabulary for a byte move that did/// not happen; it is camelCase on the wire like everything else in the/// envelope family.#[test]fn media_upload_failure_is_camel_case_on_the_wire() { let json = serde_json::to_string(&MediaUploadFailure { filename: "00000004-VIDEO.mp4".to_string(), detail: "the server answered 413".to_string(), }) .expect("a failure serialises"); assert_eq!( json, r#"{"filename":"00000004-VIDEO.mp4","detail":"the server answered 413"}"# );}/// The status strings are the wire's, kebab-cased where the TypeScript union/// is.#[test]fn media_upload_status_keeps_the_typescript_spelling() { assert_eq!(MediaUploadStatus::Uploadable.as_str(), "uploadable"); assert_eq!( MediaUploadStatus::UnsupportedType.as_str(), "unsupported-type" ); assert_eq!(MediaUploadStatus::Oversize.as_str(), "oversize"); assert_eq!(MediaUploadStatus::Missing.as_str(), "missing"); assert_eq!(MediaUploadStatus::Omitted.as_str(), "omitted"); assert_eq!( serde_json::to_string(&MediaUploadStatus::UnsupportedType).unwrap(), r#""unsupported-type""# );}