Files
turso/postgres/tests
Pekka Enberg 1ab119da0b tests: delete temporary databases instead of leaking them
Test helpers called `TempDir::keep()`, which hands back the path and
gives up the deletion guard, so every run left database files, their WAL
sidecars, and the containing directories behind in the system temp
directory. Tests that used `NamedTempFile` leaked the same way, since
the sidecars the engine writes next to the database are not covered by
the named file's guard.

Helpers now return the `TempDir` to the caller so the directory dies
with the test, and databases live inside a directory rather than being
a bare temp file. Two cases cannot use plain scoping:

  - `TempDatabase` callers routinely keep the path, drop the database to
    close it, and reopen the file to check what was written. Deleting on
    drop would pull the file out from under them, so those directories
    are parked in a process-global list that a `ctor::dtor` clears at
    exit.
  - The child process spawned by the file-locking test reruns the whole
    test binary and leaves through `process::exit`, so its destructors
    never run. It now gets its own TMPDIR that the parent deletes once
    the child is reaped.

Removing the databases through the guard also means they get cleaned up
when a test panics, which the explicit `remove_dir_all` calls at the end
of the WAL tests did not do.

Tests: cargo test for turso_core, core_tester (integration + fuzz), and
turso_pg_tests, each with an isolated TMPDIR; nothing left behind
afterwards except a lock file owned by the serial_test crate.
2026-08-06 16:31:39 +03:00
..