Skip to content

Commit bc21245

Browse files
steipetePeter Steinberger
andauthored
test(node-host): reuse approvals database fixture (#118517)
Co-authored-by: Peter Steinberger <[email protected]>
1 parent 1333238 commit bc21245

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎src/node-host/invoke-system-run.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
getRuntimeConfigSnapshot,
2020
setRuntimeConfigSnapshot,
2121
} from "../config/runtime-snapshot.js";
22+
import { deleteExecApprovalsConfigRow } from "../infra/exec-approvals-sqlite.js";
2223
import { testing as execApprovalsStoreTesting } from "../infra/exec-approvals-store.test-support.js";
2324
import type { SystemRunApprovalPlan } from "../infra/exec-approvals.js";
2425
import {
@@ -30,8 +31,10 @@ import {
3031
import type { ExecAutoReviewer } from "../infra/exec-auto-review.js";
3132
import type { ExecHostResponse } from "../infra/exec-host.js";
3233
import { formatExecCommand } from "../infra/system-run-command.js";
33-
import { closeOpenClawStateDatabaseForTest } from "../state/openclaw-state-db.js";
34-
import { resolveOpenClawStateSqlitePath } from "../state/openclaw-state-db.paths.js";
34+
import {
35+
closeOpenClawStateDatabaseForTest,
36+
openOpenClawStateDatabase,
37+
} from "../state/openclaw-state-db.js";
3538
import { withEnvAsync } from "../test-utils/env.js";
3639
import { buildSystemRunApprovalPlan } from "./invoke-system-run-plan.js";
3740
import { handleSystemRunInvoke } from "./invoke-system-run.js";
@@ -58,6 +61,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
5861
const sharedRuntimeBins = new Set<string>();
5962

6063
beforeAll(() => {
64+
closeOpenClawStateDatabaseForTest();
6165
sharedFixtureRoot = fs.realpathSync(
6266
fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-node-host-fixtures-")),
6367
);
@@ -68,6 +72,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
6872
});
6973

7074
afterAll(() => {
75+
closeOpenClawStateDatabaseForTest();
7176
if (sharedFixtureRoot) {
7277
fs.rmSync(sharedFixtureRoot, { recursive: true, force: true });
7378
}
@@ -82,14 +87,13 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
8287
beforeEach(() => {
8388
previousOpenClawHome = process.env.OPENCLAW_HOME;
8489
process.env.OPENCLAW_HOME = sharedOpenClawHome;
85-
closeOpenClawStateDatabaseForTest();
86-
fs.rmSync(resolveOpenClawStateSqlitePath(), { force: true });
8790
execApprovalsStoreTesting.reset();
91+
// Cases isolate the canonical policy row, not shared-state schema bootstrap.
92+
deleteExecApprovalsConfigRow(openOpenClawStateDatabase().db);
8893
clearRuntimeConfigSnapshot();
8994
});
9095

9196
afterEach(() => {
92-
closeOpenClawStateDatabaseForTest();
9397
execApprovalsStoreTesting.reset();
9498
clearRuntimeConfigSnapshot();
9599
if (previousOpenClawHome === undefined) {

0 commit comments

Comments
 (0)