Skip to content

Commit b48e42e

Browse files
committed
enhance test_drop_table_is_transactional further
1 parent fb9bfec commit b48e42e

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

crates/datastore/src/locking_tx_datastore/datastore.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,7 +3065,7 @@ mod tests {
30653065
let (datastore, mut tx, table_id) = setup_table()?;
30663066

30673067
// Insert a row and commit.
3068-
let row = random_row();
3068+
let row: ProductValue = random_row();
30693069
insert(&datastore, &mut tx, table_id, &row)?;
30703070
commit(&datastore, tx)?;
30713071

@@ -3088,22 +3088,30 @@ mod tests {
30883088
let _ = datastore.rollback_mut_tx(tx);
30893089

30903090
// Ensure the table still exists in the next transaction.
3091-
let tx = begin_mut_tx(&datastore);
3091+
let mut tx = begin_mut_tx(&datastore);
30923092
assert_eq!(tx.pending_schema_changes(), []);
30933093
assert!(
30943094
datastore.table_id_exists_mut_tx(&tx, &table_id),
30953095
"Table should still exist",
30963096
);
3097-
assert_eq!(all_rows(&datastore, &tx, table_id), [row]);
3098-
let _ = datastore.rollback_mut_tx(tx);
3097+
assert_eq!(all_rows(&datastore, &tx, table_id), [row.clone()]);
30993098

3100-
let mut tx = begin_mut_tx(&datastore);
3099+
// Now drop the table again and commit.
31013100
assert!(datastore.drop_table_mut_tx(&mut tx, table_id).is_ok());
3102-
commit(&datastore, tx)?;
3101+
let tx_data = commit(&datastore, tx)?;
3102+
let (_, deleted) = tx_data
3103+
.deletes()
3104+
.find(|(id, _)| **id == table_id)
3105+
.expect("should have deleted rows for `table_id`");
3106+
assert_eq!(&**deleted, [row]);
31033107

3104-
let tx = begin_mut_tx(&datastore);
3108+
// In the next transaction, the table doesn't exist.
31053109
assert!(
3106-
!datastore.table_id_exists_mut_tx(&tx, &table_id),
3110+
!datastore.table_id_exists_mut_tx(&begin_mut_tx(&datastore), &table_id),
3111+
"Table should be removed",
3112+
);
3113+
assert!(
3114+
!datastore.table_id_exists_tx(&begin_tx(&datastore), &table_id),
31073115
"Table should be removed",
31083116
);
31093117

0 commit comments

Comments
 (0)