From 39ae04fcc1e25d6b252a7432dfc8257e41237750 Mon Sep 17 00:00:00 2001 From: aur-build Date: Fri, 20 Nov 2026 20:33:11 +0000 Subject: db: move the state-enum tests into the model that declares them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/state_machine.rs was built around a database, so two tests that asserted nothing about a database still sat there: the column-text round trip, and the enumeration of the transition table. Both moved into src/db/model/build_state.rs, where `BuildState` and its table are declared. Making them in-module tests is what let the table stop being public. `ALL` and `can_transition` had no reader outside db/model at all — production enforces transitions by asking `predecessors(to)` and putting the answer in a SQL `WHERE state IN (...)` guard — so both are now private, and the five state enums' `ALL` consts with them. One assertion moved rather than being dropped. `a_terminal_build_is_history_and_does_not_move` made two claims per state: a table claim (`!Succeeded.can_transition(to)`) and a database claim (`set_state(...).is_err()`). The table claim now lives with the table; the database claim stayed where the database is. Neither was weakened. Two findings, recorded rather than quietly acted on: `ReleaseState::can_transition` and `SubscriptionState::can_transition` are consulted by nothing — not by `predecessors`, not by a test. They are dead tables for machines nothing enforces. Left `pub` with a NOTE and handed to the disposition table, because deleting a stated invariant and wiring up an unwired one are both decisions above this commit. Added two round-trip tests (StepState, and the three enums declared in state.rs) so the newly private `ALL` consts are still exercised. db: 202 pub / 13 test-only -> 201 pub / 11 test-only. Suite: 283 passed, 0 failed, 0 ignored. Clippy clean. --- tests/config.rs | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'tests/config.rs') diff --git a/tests/config.rs b/tests/config.rs index a45ac1b..6c58122 100644 --- a/tests/config.rs +++ b/tests/config.rs @@ -116,22 +116,6 @@ fn an_absolute_root_is_used_verbatim() { assert_eq!(Config::load(dir).unwrap().root, dir); } -fn load_sandbox(sandbox: &str) -> Result { - let tmp = tempfile::tempdir().unwrap(); - std::fs::write( - tmp.path().join("config.json"), - format!("{{\n \"sandbox\": {sandbox}\n}}\n"), - ) - .unwrap(); - Config::load(tmp.path()).map_err(|e| e.to_string()) -} - -fn load_raw(body: &str) -> Result { - let tmp = tempfile::tempdir().unwrap(); - std::fs::write(tmp.path().join("config.json"), body).unwrap(); - Config::load(tmp.path()).map_err(|e| e.to_string()) -} - #[test] fn serve_refuses_a_remote_config_that_never_asserted_the_workspace() { let tmp = tempfile::tempdir().unwrap(); -- cgit v1.2.3