//! No row cascades out of the bin behind the fold's back. Every value is//! invented ([nothing-real-ever-goes-in-cotton-s-public-tree]).usesuper::*;usecrate::test_support::seeded_file;const ERASER: &str = "device:aaaa";/// RULE: Every bin table is a real table with its bin marker, and no table's delete cascades from a bin row — so an erase takes exactly the rows it names, never a child SQLite removed behind it.#[test]fn no_table_a_bin_row_cascades_into() {let db = seeded_file(ERASER);let tables: Vec<String> = db .all("SELECT name FROM sqlite_master WHERE type = 'table'", &[]) .expect("reads") .iter() .filter_map(|row| row.text("name").map(str::to_string)) .collect();for (table, marker, _) in BIN_TABLES {let columns = db .all(&format!("PRAGMA table_info({table})"), &[]) .expect("reads the columns"); assert!( columns.iter().any(|column| column.text("name") == Some(*marker)),"{table} has no {marker}" ); }letmut cascades = Vec::new();for child in &tables {let keys = db .all(&format!("PRAGMA foreign_key_list({child})"), &[]) .expect("reads the foreign keys");for key in keys {let parent = key.text("table").unwrap_or_default();let on_delete = key.text("on_delete").unwrap_or_default();if BIN_TABLES.iter().any(|(table, _, _)| *table == parent) && on_delete == "CASCADE" { cascades.push(child.clone()); } } } assert!(cascades.is_empty(), "a bin row's delete cascades into {cascades:?}");}