feat(seed): --seed flag, ambient wiring, and /runda hardening (ADR-0048 P1.4 + DA)
P1.4 — user-visible surface: - Grammar: `seed <table> [count] [--seed <n>]` (the first DSL flag with a value); build_seed disambiguates the seed value from the positional count. - Verified the auto-wired surface: table-name completion, --seed offered as a candidate, validity consistent with `show data`, an ADR-0042 near-miss row for bare `seed`, and render tests for the seed outcome. /runda hardening — eight DA findings, all resolved: - FK sampling now uses ORDER BY so --seed reproducibility no longer relies on SQLite's unspecified DISTINCT order (D4). - shortid columns now generate from seed's seeded RNG (new shortid::generate_with_rng) — D4 now holds with no exceptions. - Added the missing coverage the DA flagged: undo-one-step (D15), replay re-runs a seed line (D16), advanced-mode (D5), atomic rollback on a constraint failure, seed 0 no-op, complex-CHECK advisory (D17), and FK + shortid reproducibility. 2358 pass / 0 fail / 0 skip, clippy all-targets clean.
This commit is contained in:
@@ -441,3 +441,40 @@ fn smoke_assess_parse_label_round_trips() {
|
||||
assert_eq!(a.parse_result.as_deref(), Ok("Insert"));
|
||||
assert!(matches!(a.state, InputState::Valid));
|
||||
}
|
||||
|
||||
/// `seed` (ADR-0048) gets the standard ambient surface for free from
|
||||
/// grammar registration: table-name completion, the validity indicator
|
||||
/// flagging an unknown table, and the `--seed` flag offered as a
|
||||
/// candidate.
|
||||
#[test]
|
||||
fn seed_completion_and_validity() {
|
||||
let schema = schema_serial_pk(); // Customers(id serial, Name, Email)
|
||||
|
||||
// Completion: `seed ` offers existing table names.
|
||||
let cands = completion_candidate_texts(&assess_at_end("seed ", &schema));
|
||||
assert!(
|
||||
cands.iter().any(|c| c == "Customers"),
|
||||
"`seed ` should complete table names, got {cands:?}"
|
||||
);
|
||||
|
||||
// Validity (ADR-0027): a known table seeds clean; an unknown one is
|
||||
// flagged (same table slot as update/delete/show data).
|
||||
let ok = assess_at_end("seed Customers 5", &schema);
|
||||
assert!(matches!(ok.state, InputState::Valid), "known table: {:?}", ok.state);
|
||||
// seed's unknown-table behaviour must match its closest sibling
|
||||
// `show data` (same table-only slot), whatever that is.
|
||||
let seed_ghost = assess_at_end("seed Ghost 5", &schema).state;
|
||||
let show_ghost = assess_at_end("show data Ghost", &schema).state;
|
||||
assert_eq!(
|
||||
std::mem::discriminant(&seed_ghost),
|
||||
std::mem::discriminant(&show_ghost),
|
||||
"seed should treat an unknown table like `show data`: seed={seed_ghost:?}, show={show_ghost:?}"
|
||||
);
|
||||
|
||||
// The `--seed` reproducibility flag is offered after the count.
|
||||
let flag_cands = completion_candidate_texts(&assess_at_end("seed Customers 5 ", &schema));
|
||||
assert!(
|
||||
flag_cands.iter().any(|c| c.contains("seed")),
|
||||
"`--seed` should be offered as a candidate, got {flag_cands:?}"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user