Files
rdbms-playground/tests/typing_surface/delete_with_where.rs
T
claude@clouddev1 41b7e9a049 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.
2026-06-17 21:39:19 +00:00

78 lines
2.5 KiB
Rust

//! Matrix coverage for `delete from T where col=val` (ADR-0014).
use crate::typing_surface::*;
use rdbms_playground::input_render::InputState;
#[test]
fn after_delete_expects_from() {
let schema = schema_serial_pk();
let a = assess_at_end("delete ", &schema);
assert!(matches!(a.state, InputState::IncompleteAtEof));
assert_candidate_present(&a, &["from"]);
crate::snap!("after_delete", a);
}
#[test]
fn after_from_offers_table_names() {
let schema = schema_multi_table();
let a = assess_at_end("delete from ", &schema);
assert_candidate_present(&a, &["Customers", "Orders"]);
crate::snap!("after_from", a);
}
#[test]
fn after_table_expects_filter_clause() {
let schema = schema_serial_pk();
let a = assess_at_end("delete from Customers ", &schema);
assert!(matches!(a.state, InputState::IncompleteAtEof));
assert_candidate_present(&a, &["where", "--all-rows"]);
crate::snap!("after_table_name", a);
}
#[test]
fn after_where_offers_active_table_columns_no_leakage() {
let schema = schema_multi_table();
let a = assess_at_end("delete from Customers where ", &schema);
assert!(matches!(a.state, InputState::IncompleteAtEof));
assert_candidate_present(&a, &["id", "Name"]);
assert_no_candidate_named(&a, &["OrderId", "CustId", "Total"]);
crate::snap!("after_where", a);
}
#[test]
fn after_where_column_equals_offers_typed_prose() {
let schema = schema_serial_pk();
let a = assess_at_end("delete from Customers where Email=", &schema);
let prose = hint_prose(&a).unwrap_or_else(|| panic!("expected Prose, got {:?}", a.hint));
assert!(
prose.contains("Email"),
"should name `Email`, got prose: {prose:?}",
);
assert!(
prose.contains("quoted string"),
"should say `quoted string`, got prose: {prose:?}",
);
crate::snap!("after_where_equals", a);
}
#[test]
fn complete_delete_with_where_parses() {
let schema = schema_serial_pk();
let a = assess_at_end("delete from Customers where id=1", &schema);
assert!(matches!(a.state, InputState::Valid));
assert_eq!(a.parse_result.as_deref(), Ok("Delete"));
crate::snap!("complete_delete", a);
}
#[test]
fn delete_with_datetime_column_says_yyyy_mm_dd_t() {
let schema = schema_every_type();
let a = assess_at_end("delete from Things where ts=", &schema);
let prose = hint_prose(&a).unwrap_or_else(|| panic!("expected Prose, got {:?}", a.hint));
assert!(
prose.contains("ts"),
"should name `ts`, got prose: {prose:?}",
);
crate::snap!("datetime_column", a);
}