Skip to content

Commit 7369497

Browse files
committed
test(memory-core): release cached handles in the shared fixture harness and cli teardown
1 parent 2cf7b94 commit 7369497

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎extensions/memory-core/src/cli.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import path from "node:path";
55
import { Command } from "commander";
66
import type { OpenClawConfig } from "openclaw/plugin-sdk/memory-core-host-engine-foundation";
77
import { resolveSessionTranscriptsDirForAgent as resolveTestSessionTranscriptsDirForAgent } from "openclaw/plugin-sdk/memory-core-host-runtime-core";
8+
import { resetPluginStateStoreForTests } from "openclaw/plugin-sdk/plugin-state-test-runtime";
89
import { upsertSessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
910
import { appendSessionTranscriptMessageByIdentity } from "openclaw/plugin-sdk/session-transcript-runtime";
1011
import { resolveOpenClawAgentSqlitePath } from "openclaw/plugin-sdk/sqlite-runtime";
@@ -161,6 +162,10 @@ afterAll(async () => {
161162
if (!fixtureRoot) {
162163
return;
163164
}
165+
// The agent close releases its leases through shared state and reopens it, so the
166+
// shared handle is released second; otherwise Windows fails the removal with EBUSY.
167+
closeOpenClawAgentDatabasesForTest();
168+
resetPluginStateStoreForTests();
164169
await fs.rm(fixtureRoot, { recursive: true, force: true });
165170
resetMemoryCoreDreamingStateForTests();
166171
});

‎extensions/memory-core/src/test-helpers.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
import fs from "node:fs/promises";
33
import path from "node:path";
44
import type { OpenKeyedStoreOptions } from "openclaw/plugin-sdk/plugin-state-runtime";
5-
import { createPluginStateKeyedStoreForTests } from "openclaw/plugin-sdk/plugin-state-test-runtime";
5+
import {
6+
createPluginStateKeyedStoreForTests,
7+
resetPluginStateStoreForTests,
8+
} from "openclaw/plugin-sdk/plugin-state-test-runtime";
9+
import { closeOpenClawAgentDatabasesForTest } from "openclaw/plugin-sdk/sqlite-runtime-testing";
610
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
711
import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
812
import { afterAll, beforeAll } from "vitest";
@@ -210,6 +214,10 @@ export function createMemoryCoreTestHarness() {
210214
if (!fixtureRoot) {
211215
return;
212216
}
217+
// The agent close releases its leases through shared state and reopens it, so the
218+
// shared handle is released second; otherwise Windows fails the removal with EBUSY.
219+
closeOpenClawAgentDatabasesForTest();
220+
resetPluginStateStoreForTests();
213221
await fs.rm(fixtureRoot, { recursive: true, force: true });
214222
resetMemoryCoreDreamingStateForTests();
215223
});

0 commit comments

Comments
 (0)