DRY pass #3: core tests open their store and seed a label one way (#5373)

Five test modules wrote the same db() over memory_conn, and portable.rs
unwrapped it inline; local::test_db() is that. Four pull/push tests wrote the
same label INSERT; local::seed_label(conn, id, name, dirty) is it. Both are
cfg(test), beside memory_conn, as wire::sample_note is beside wire::Note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 15:17:30 -04:00
co-authored by Claude Opus 5.5
parent 1b128a9374
commit 78810d8832
7 changed files with 27 additions and 40 deletions
+3 -15
View File
@@ -508,9 +508,7 @@ pub async fn run(
mod tests {
use super::*;
fn db() -> Connection {
crate::local::memory_conn().expect("in-memory db")
}
use crate::local::test_db as db;
fn note(id: &str, revision: i64) -> wire::Note {
wire::sample_note(id, revision)
@@ -738,12 +736,7 @@ mod tests {
#[test]
fn server_label_replaces_a_local_duplicate_by_name() {
let conn = db();
conn.execute(
"INSERT INTO labels (id, name, color, created_at, updated_at, dirty)
VALUES ('local-id', 'Work', 'default', '2026-01-01', '2026-01-01', 1)",
[],
)
.expect("seed local label");
crate::local::seed_label(&conn, "local-id", "Work", 1);
let server = wire::Label {
id: "server-id".into(),
@@ -768,12 +761,7 @@ mod tests {
// plain delete would strip the label off them with nothing to repair it.
let conn = db();
apply_page(&conn, &page(vec![note("n1", 1)], vec![], 1)).expect("seed note");
conn.execute(
"INSERT INTO labels (id, name, color, created_at, updated_at, dirty)
VALUES ('local-id', 'Work', 'default', '2026-01-01', '2026-01-01', 1)",
[],
)
.expect("seed local label");
crate::local::seed_label(&conn, "local-id", "Work", 1);
conn.execute(
"INSERT INTO note_labels (note_id, label_id, via_tag)
VALUES ('n1', 'local-id', 0)",