Documentation
¶
Overview ¶
Package testvault provides shared, per-process test fixtures built from the committed fixture vault. It builds the vault index once per test binary and hands out fresh copies to individual tests, cutting package-level test time from N*rebuild to 1*rebuild + N*file-copy. Test-only; not imported by production code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FixtureVault ¶ added in v0.1.2
func FixtureVault() string
FixtureVault returns the path to the committed test fixture vault (test/fixtures/testvault), resolved relative to THIS source file so tests never hardcode a fragile relative path or depend on a personal vault. The fixture is a small, generic cognitive-science vault sized to satisfy the graph/resolve/index tests (it carries the same note ids they assert).
func IndexedFixtureVault ¶ added in v0.1.2
IndexedFixtureVault copies the fixture vault into a fresh temp dir, builds its index there, and returns the temp vault path — for tests that need a vault directory with a real .vaultmind/index.db (e.g. cmdutil.OpenVaultDB), rather than the raw shared DB from OpenSharedDB.
func OpenSharedDB ¶
OpenSharedDB copies the shared, pre-built DB to dstPath and opens it for exclusive use by the caller's test. The caller owns the returned *index.DB and is responsible for closing it (typically via t.Cleanup).
func SharedIndexDBPath ¶
SharedIndexDBPath returns the filesystem path of an index DB built from vaultPath, rebuilt exactly once per test process. Callers must NOT mutate the returned file — use OpenSharedDB to obtain a writable per-test copy.
The first caller's vaultPath wins for the process lifetime; a subsequent call with a different vaultPath fails loudly rather than silently returning the first vault's DB. Every caller in this repo uses the same fixture vault, so the single-path lock is the honest contract.
WAL/SHM sidecars are intentionally not copied: Indexer.Rebuild closes the only DB handle before returning, which triggers SQLite's default WAL checkpoint/truncation, leaving all committed state in the main .db file. If a future change keeps the DB open after Rebuild, or disables wal_autocheckpoint, the sidecars would need to be copied too — otherwise per-test copies silently lose the tail of the rebuild.
Types ¶
This section is empty.