Core tests open their store through local::memory_conn

Seven test modules each built a migrated in-memory store by hand: open, migrate,
and (in sharing) wrap it in a Db. local::memory_conn() is that, and
open_in_memory uses it too. Each module's db() is now one line, and the schema,
Connection and Mutex imports it needed are gone.

DRY pass #2, batch 2, F9 (#5372).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 14:24:04 -04:00
co-authored by Claude Opus 5.5
parent c35e7fd589
commit 3ea7c817bf
8 changed files with 14 additions and 30 deletions
+1 -4
View File
@@ -507,12 +507,9 @@ pub async fn run(
#[cfg(test)]
mod tests {
use super::*;
use crate::local::schema;
fn db() -> Connection {
let conn = Connection::open_in_memory().expect("in-memory db");
schema::migrate(&conn).expect("migrate");
conn
crate::local::memory_conn().expect("in-memory db")
}
fn note(id: &str, revision: i64) -> wire::Note {
+1 -4
View File
@@ -702,13 +702,10 @@ pub fn parse_results(raw: &str) -> Result<Vec<PushResult>, String> {
#[cfg(test)]
mod tests {
use super::*;
use crate::local::schema;
use crate::local::store;
fn db() -> Connection {
let conn = Connection::open_in_memory().expect("in-memory db");
schema::migrate(&conn).expect("migrate");
conn
crate::local::memory_conn().expect("in-memory db")
}
fn seed_note(conn: &Connection, id: &str, dirty: i64) {
+1 -6
View File
@@ -85,15 +85,10 @@ pub async fn unshare(
#[cfg(test)]
mod tests {
use super::*;
use crate::local::schema;
use crate::sync::client::Member;
use rusqlite::Connection;
use std::sync::Mutex;
fn db() -> Db {
let conn = Connection::open_in_memory().expect("in-memory db");
schema::migrate(&conn).expect("migrate");
Db(Mutex::new(conn))
crate::local::open_in_memory().expect("in-memory db")
}
#[test]
+1 -4
View File
@@ -308,12 +308,9 @@ pub fn status(conn: &Connection) -> rusqlite::Result<Status> {
#[cfg(test)]
mod tests {
use super::*;
use crate::local::schema;
fn db() -> Connection {
let conn = Connection::open_in_memory().expect("in-memory db");
schema::migrate(&conn).expect("migrate");
conn
crate::local::memory_conn().expect("in-memory db")
}
#[test]