@@ -325,14 +325,41 @@ fn test_create_clock_table_from_table_info() {
325325}
326326
327327fn test_leak_condition ( ) {
328- // updating table infos prepares stements
328+ // updating schemas prepares stements
329329 // re-pulling table infos should finalize those statements
330- // we do not use `Drop` given we cannot return error conditions from `Drop`
330+ let c1w = crate :: opendb_file ( "test_leak_condition" ) . expect ( "Opened DB" ) ;
331+ let c2w = crate :: opendb_file ( "test_leak_condition" ) . expect ( "Opened DB" ) ;
332+
333+ let c1 = & c1w. db ;
334+ let c2 = & c2w. db ;
335+
336+ c1. exec_safe (
337+ "DROP TABLE IF EXISTS foo;
338+ DROP TABLE IF EXISTS bar;
339+ VACUUM;" ,
340+ )
341+ . expect ( "reset db" ) ;
342+
343+ c1. exec_safe ( "CREATE TABLE foo (a not null, b not null, primary key (a, b));" )
344+ . expect ( "made foo" ) ;
345+ c1. exec_safe ( "SELECT crsql_as_crr('foo')" )
346+ . expect ( "made foo a crr" ) ;
347+ c1. exec_safe ( "INSERT INTO foo VALUES (1, 2)" )
348+ . expect ( "inserted into foo" ) ;
349+ c1. exec_safe ( "UPDATE FOO set b = 3" ) . expect ( "updated foo" ) ;
350+ c2. exec_safe ( "INSERT INTO foo VALUES (2, 3)" )
351+ . expect ( "inserted into foo" ) ;
352+ c2. exec_safe ( "CREATE TABLE bar (a)" ) . expect ( "created bar" ) ;
353+ c1. exec_safe ( "INSERT INTO foo VALUES (3, 4)" )
354+ . expect ( "inserted into foo" ) ;
355+ c2. exec_safe ( "INSERT INTO foo VALUES (4, 5)" )
356+ . expect ( "inserted into foo" ) ;
331357}
332358
333359pub fn run_suite ( ) {
334360 test_ensure_table_infos_are_up_to_date ( ) ;
335361 test_pull_table_info ( ) ;
336362 test_is_table_compatible ( ) ;
337363 test_create_clock_table_from_table_info ( ) ;
364+ test_leak_condition ( ) ;
338365}
0 commit comments