MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / remove_empty_table_succeeds

Function remove_empty_table_succeeds

crates/engine/src/update.rs:902–932  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

900
901 #[test]
902 fn remove_empty_table_succeeds() -> anyhow::Result<()> {
903 let auth_ctx = AuthCtx::for_testing();
904 let stdb = TestDB::durable()?;
905
906 let old = single_table_module();
907 let new = empty_module();
908
909 let mut tx = begin_mut_tx(&stdb);
910 for def in old.tables() {
911 create_table_from_def(&stdb, &mut tx, &old, def)?;
912 }
913 stdb.commit_tx(tx)?;
914
915 let mut tx = begin_mut_tx(&stdb);
916 let plan = ponder_migrate(&old, &new)?;
917 let res = update_database(&stdb, &mut tx, auth_ctx, plan, &TestLogger)?;
918
919 assert!(
920 matches!(res, UpdateResult::RequiresClientDisconnect),
921 "removing a table should disconnect clients"
922 );
923 assert!(stdb.table_id_from_name_mut(&tx, "droppable")?.is_none());
924 assert!(
925 tx.pending_schema_changes()
926 .iter()
927 .any(|c| matches!(c, PendingSchemaChange::TableRemoved(..))),
928 "dropping a table should produce a TableRemoved pending schema change: {:?}",
929 tx.pending_schema_changes()
930 );
931 Ok(())
932 }
933
934 #[test]
935 fn remove_nonempty_table_fails() -> anyhow::Result<()> {

Callers

nothing calls this directly

Calls 9

single_table_moduleFunction · 0.85
empty_moduleFunction · 0.85
create_table_from_defFunction · 0.85
ponder_migrateFunction · 0.85
update_databaseFunction · 0.85
commit_txMethod · 0.80
begin_mut_txFunction · 0.70
OkFunction · 0.50
tablesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…