()
| 933 | |
| 934 | #[test] |
| 935 | fn remove_nonempty_table_fails() -> anyhow::Result<()> { |
| 936 | let auth_ctx = AuthCtx::for_testing(); |
| 937 | let stdb = TestDB::durable()?; |
| 938 | |
| 939 | let old = single_table_module(); |
| 940 | let new = empty_module(); |
| 941 | |
| 942 | let mut tx = begin_mut_tx(&stdb); |
| 943 | for def in old.tables() { |
| 944 | create_table_from_def(&stdb, &mut tx, &old, def)?; |
| 945 | } |
| 946 | let table_id = stdb |
| 947 | .table_id_from_name_mut(&tx, "droppable")? |
| 948 | .expect("table should exist"); |
| 949 | insert(&stdb, &mut tx, table_id, &product![42u64])?; |
| 950 | stdb.commit_tx(tx)?; |
| 951 | |
| 952 | let mut tx = begin_mut_tx(&stdb); |
| 953 | let plan = ponder_migrate(&old, &new)?; |
| 954 | let result = update_database(&stdb, &mut tx, auth_ctx, plan, &TestLogger); |
| 955 | let err = result.err().expect("removing a non-empty table should fail"); |
| 956 | assert!( |
| 957 | err.to_string().contains("table contains data"), |
| 958 | "error should mention that the table contains data, got: {err}" |
| 959 | ); |
| 960 | assert!( |
| 961 | tx.pending_schema_changes().is_empty(), |
| 962 | "failed migration should leave no pending schema changes: {:?}", |
| 963 | tx.pending_schema_changes() |
| 964 | ); |
| 965 | Ok(()) |
| 966 | } |
| 967 | |
| 968 | /// Verifies that `autoinc` sequence survives a schema migration that adds a column, |
| 969 | /// and is also correctly persisted across database replay. |
nothing calls this directly
no test coverage detected
searching dependent graphs…