mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-16 20:22:21 +03:00
fix(db): keep test runs off the operator's real DATA_DIR (#10432)
Any process that opened the DB without setting DATA_DIR resolved to ~/.omniroute/storage.sqlite — the operator's live database, provider credentials included. tests/_setup/isolateDataDir.ts only covers the npm scripts; the documented single-file test command and ad-hoc probes bypassed it (one did exactly that during #10334). resolveWritableDataDir now redirects a test-context process with no DATA_DIR to a throwaway temp dir, stable per process. Redirect rather than throw, so the documented single-file command keeps working; OMNIROUTE_ALLOW_DEFAULT_DATA_DIR=1 opts back in and records the intent. Closes #10428
This commit is contained in:
committed by
GitHub
parent
50cb187511
commit
2a04b2415a
@@ -84,6 +84,11 @@ test("resolveWritableDataDir falls back to the default dir when DATA_DIR is not
|
||||
test("resolveWritableDataDir returns the default dir (no probe) when DATA_DIR is unset", async () => {
|
||||
await withTempEnv(() => {
|
||||
delete process.env.DATA_DIR;
|
||||
// #10428: this asserts the SERVER path. Since the test-context guard now redirects a
|
||||
// DATA_DIR-less test process to a temp dir (so a test can never open the operator's
|
||||
// real DB), opt back in explicitly here — otherwise this test would be asserting the
|
||||
// guard's behavior instead of the server's.
|
||||
process.env.OMNIROUTE_ALLOW_DEFAULT_DATA_DIR = "1";
|
||||
const resolved = resolveWritableDataDir();
|
||||
assert.equal(resolved, getDefaultDataDir());
|
||||
// Matches the pure resolver when no override is present.
|
||||
|
||||
Reference in New Issue
Block a user