From 2809c2621463a9a47c237e2c1b19aec28052dc67 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 8 Oct 2026 14:25:14 -0400 Subject: [PATCH] Sync tests build a server note from wire::sample_note pull's note() and push's server_note each wrote out all nineteen fields of a wire::Note. wire::sample_note(id, revision) is that note; push's version changes only the body and attachments, by struct update. DRY pass #2, batch 2, F9 (#5372). Co-Authored-By: Claude Opus 5.5 --- core/src/sync/pull.rs | 22 +--------------------- core/src/sync/push.rs | 18 +----------------- core/src/sync/wire.rs | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 38 deletions(-) diff --git a/core/src/sync/pull.rs b/core/src/sync/pull.rs index 1d80ed4..478f23f 100644 --- a/core/src/sync/pull.rs +++ b/core/src/sync/pull.rs @@ -513,27 +513,7 @@ mod tests { } fn note(id: &str, revision: i64) -> wire::Note { - wire::Note { - id: id.to_string(), - body: "Body".into(), - position: 0, - pinned: false, - archived: false, - trashed: false, - deleted_at: None, - remind_at: None, - recurrence: None, - created_at: Some("2026-07-26T00:00:00.000Z".into()), - updated_at: Some("2026-07-26T00:00:00.000Z".into()), - sync_revision: revision, - purged_at: None, - labels: vec![], - attachments: vec![], - previews: vec![], - permission: None, - shared: false, - shared_by: None, - } + wire::sample_note(id, revision) } fn attachment(id: &str) -> wire::Attachment { diff --git a/core/src/sync/push.rs b/core/src/sync/push.rs index 9aa3305..2248bb3 100644 --- a/core/src/sync/push.rs +++ b/core/src/sync/push.rs @@ -1059,25 +1059,9 @@ mod tests { use crate::sync::{pull, wire}; let conn = db(); let server_note = |revision: i64, attachments: Vec| wire::Note { - id: "n1".into(), body: "a note".into(), - position: 0, - pinned: false, - archived: false, - trashed: false, - deleted_at: None, - remind_at: None, - recurrence: None, - created_at: Some("2026-07-26T00:00:00.000Z".into()), - updated_at: Some("2026-07-26T00:00:00.000Z".into()), - sync_revision: revision, - purged_at: None, - labels: vec![], attachments, - previews: vec![], - permission: None, - shared: false, - shared_by: None, + ..wire::sample_note("n1", revision) }; let page = |note: wire::Note, cursor: i64| wire::ChangesPage { notes: vec![note], diff --git a/core/src/sync/wire.rs b/core/src/sync/wire.rs index 6bb2efe..224d58e 100644 --- a/core/src/sync/wire.rs +++ b/core/src/sync/wire.rs @@ -165,3 +165,30 @@ fn default_color() -> String { fn default_mime() -> String { OPAQUE_MIME.to_string() } + +/// A plain note, this account's own and live, as a server sends it. For tests in +/// pull and push, which each wrote the whole literal out. +#[cfg(test)] +pub(crate) fn sample_note(id: &str, revision: i64) -> Note { + Note { + id: id.to_string(), + body: "Body".into(), + position: 0, + pinned: false, + archived: false, + trashed: false, + deleted_at: None, + remind_at: None, + recurrence: None, + created_at: Some("2026-07-26T00:00:00.000Z".into()), + updated_at: Some("2026-07-26T00:00:00.000Z".into()), + sync_revision: revision, + purged_at: None, + labels: vec![], + attachments: vec![], + previews: vec![], + permission: None, + shared: false, + shared_by: None, + } +}