style: format the whole tree with cargo fmt (stock defaults, #35)

One-time, mechanical reformat — no functional changes. The tree was not
rustfmt-clean (~1800 hunks across ~100 files); this brings it to stock
`cargo fmt` defaults so a `cargo fmt --check` CI gate can follow.
Behaviour-preserving: 2509 pass / 0 fail / 1 ignored (unchanged baseline),
clippy clean. A .git-blame-ignore-revs entry follows so `git blame`
skips this commit.
This commit is contained in:
claude@clouddev1
2026-06-17 21:39:19 +00:00
parent e9606b5f6d
commit 41b7e9a049
102 changed files with 8017 additions and 4975 deletions
+66 -19
View File
@@ -22,8 +22,7 @@ fn rt() -> tokio::runtime::Runtime {
fn open(undo: bool) -> (project::Project, Database, tempfile::TempDir) {
let dir = tempfile::tempdir().expect("create tempdir");
let project =
project::open_or_create(None, Some(dir.path())).expect("open or create project");
let project = project::open_or_create(None, Some(dir.path())).expect("open or create project");
let persistence = Persistence::new(project.path().to_path_buf());
let db = Database::open_with_persistence_and_undo(project.db_path(), persistence, undo)
.expect("open db with persistence");
@@ -34,7 +33,10 @@ fn open(undo: bool) -> (project::Project, Database, tempfile::TempDir) {
fn make_t(db: &Database, r: &tokio::runtime::Runtime) {
r.block_on(db.sql_create_table(
"T".to_string(),
vec![ColumnSpec::new("id", Type::Int), ColumnSpec::new("body", Type::Text)],
vec![
ColumnSpec::new("id", Type::Int),
ColumnSpec::new("body", Type::Text),
],
vec!["id".to_string()],
vec![],
vec![],
@@ -54,7 +56,11 @@ fn drop_table_removes_an_existing_table() {
.block_on(db.sql_drop_table("T".to_string(), false, Some("drop table T".to_string())))
.expect("drop");
assert!(matches!(out, DropOutcome::Dropped));
assert!(!r.block_on(db.list_tables()).unwrap().contains(&"T".to_string()));
assert!(
!r.block_on(db.list_tables())
.unwrap()
.contains(&"T".to_string())
);
}
#[test]
@@ -75,8 +81,15 @@ fn if_exists_on_an_absent_table_is_a_noop_and_journalled() {
fn plain_drop_of_an_absent_table_errors() {
let (_p, db, _d) = open(false);
let r = rt();
let res = r.block_on(db.sql_drop_table("Ghost".to_string(), false, Some("drop table Ghost".to_string())));
assert!(res.is_err(), "plain DROP TABLE on an absent table errors (no IF EXISTS)");
let res = r.block_on(db.sql_drop_table(
"Ghost".to_string(),
false,
Some("drop table Ghost".to_string()),
));
assert!(
res.is_err(),
"plain DROP TABLE on an absent table errors (no IF EXISTS)"
);
}
#[test]
@@ -87,7 +100,10 @@ fn dropping_a_referenced_parent_is_refused() {
let r = rt();
r.block_on(db.sql_create_table(
"parent".to_string(),
vec![ColumnSpec::new("id", Type::Serial), ColumnSpec::new("label", Type::Text)],
vec![
ColumnSpec::new("id", Type::Serial),
ColumnSpec::new("label", Type::Text),
],
vec!["id".to_string()],
vec![],
vec![],
@@ -98,7 +114,10 @@ fn dropping_a_referenced_parent_is_refused() {
.expect("create parent");
r.block_on(db.sql_create_table(
"child".to_string(),
vec![ColumnSpec::new("id", Type::Serial), ColumnSpec::new("pid", Type::Int)],
vec![
ColumnSpec::new("id", Type::Serial),
ColumnSpec::new("pid", Type::Int),
],
vec!["id".to_string()],
vec![],
vec![],
@@ -112,22 +131,36 @@ fn dropping_a_referenced_parent_is_refused() {
inline: true,
}],
false,
Some("create table child (id serial primary key, pid int references parent(id))".to_string()),
Some(
"create table child (id serial primary key, pid int references parent(id))".to_string(),
),
))
.expect("create child with FK");
// The parent is referenced — refused (even with IF EXISTS, since the
// table *does* exist; the refusal is about the relationship).
assert!(
r.block_on(db.sql_drop_table("parent".to_string(), false, Some("drop table parent".to_string())))
.is_err(),
r.block_on(db.sql_drop_table(
"parent".to_string(),
false,
Some("drop table parent".to_string())
))
.is_err(),
"a referenced parent can't be dropped"
);
// Dropping the child first succeeds, then the parent.
r.block_on(db.sql_drop_table("child".to_string(), false, Some("drop table child".to_string())))
.expect("drop child");
r.block_on(db.sql_drop_table("parent".to_string(), false, Some("drop table parent".to_string())))
.expect("now the parent drops");
r.block_on(db.sql_drop_table(
"child".to_string(),
false,
Some("drop table child".to_string()),
))
.expect("drop child");
r.block_on(db.sql_drop_table(
"parent".to_string(),
false,
Some("drop table parent".to_string()),
))
.expect("now the parent drops");
}
#[test]
@@ -138,17 +171,31 @@ fn drop_table_is_one_undo_step_and_restores_data() {
r.block_on(db.insert(
"T".to_string(),
Some(vec!["id".to_string(), "body".to_string()]),
vec![Value::Number("1".to_string()), Value::Text("hi".to_string())],
vec![
Value::Number("1".to_string()),
Value::Text("hi".to_string()),
],
Some("insert".to_string()),
))
.expect("row");
r.block_on(db.sql_drop_table("T".to_string(), false, Some("drop table T".to_string())))
.expect("drop");
assert!(!r.block_on(db.list_tables()).unwrap().contains(&"T".to_string()));
assert!(
!r.block_on(db.list_tables())
.unwrap()
.contains(&"T".to_string())
);
// One undo brings the table — and its row — back.
assert!(r.block_on(db.undo()).expect("undo").is_some(), "the drop was one undo step");
assert!(r.block_on(db.list_tables()).unwrap().contains(&"T".to_string()));
assert!(
r.block_on(db.undo()).expect("undo").is_some(),
"the drop was one undo step"
);
assert!(
r.block_on(db.list_tables())
.unwrap()
.contains(&"T".to_string())
);
let data = r
.block_on(db.query_data("T".to_string(), None, None))
.expect("query");