mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-10-01 00:32:05 +00:00
test: pin the migration chain's append-only rule
`db.rs`'s two rules — `schema_init` is the version-0 baseline and never gains a column, `MIGRATIONS` is append-only and never edited — were enforced by comments only. Both have a silent failure mode across releases, and the worst one (a baseline edit) makes `open_store` fail with `duplicate column name`, i.e. a fresh deployment that will not start. Three tests, no production change: - A pre-migration database (the historical DDL written out literally, so an edit to the baseline shows up here instead of being followed) upgrades through `open_store`: version at the latest, exactly the migrated column set, rows intact. - The shipped migration text is frozen and compared entry by entry; the assertion names the rule when it fires. Appending still passes — that is the one allowed change. - A fresh database lands at the latest version, so a deployment that only ever saw fresh databases is on the same schema as an upgraded one, and re-opening the same file is a no-op. Verified by mutation, both confirmed to fail the new tests: editing the shipped migration (`shipped_migrations_are_frozen`, with the rule in the message) and adding the column to `schema_init` instead of a migration (`a_fresh_database_lands_at_the_latest_version`, `duplicate column name: lease_token`). Docs synced for this and the previous two items: `main.rs` (startup repair), `queue.rs` (`runnable_rows`/`replace_payload`), `handlers/` (`urls.rs`'s repair, `mod.rs`'s `apply_caption_edit`), `db.rs` (the migration tests) and the untested-modules list (`db.rs` now covered for migrations; the bot-side live test renamed to match the repo's `--ignored live` filter). `cargo fmt`, `cargo clippy --workspace --all-targets --locked -- -D warnings`, `cargo test --workspace --locked` (193 passed, 15 ignored) and `cargo test -p x-media -- --ignored live` (13) clean.
This commit is contained in:
@@ -1152,7 +1152,7 @@ mod tests {
|
||||
/// rewritten in place, so the retry can still deliver it.
|
||||
#[tokio::test]
|
||||
#[ignore = "live network: requires outbound HTTPS to public.api.bsky.app"]
|
||||
async fn a_lost_local_media_row_is_refetched_from_its_post() {
|
||||
async fn live_repair_refetches_a_lost_local_media_row() {
|
||||
let stores = TestStores::new();
|
||||
// An empty script: the repair must not need to tell the user anything.
|
||||
let sender = MockSender::scripted(vec![], permanent_error);
|
||||
|
||||
Reference in New Issue
Block a user