test(memory): make mcporter EINVAL retry test deterministic
This commit is contained in:
@@ -1641,7 +1641,11 @@ describe("QmdMemoryManager", () => {
|
||||
} as OpenClawConfig;
|
||||
|
||||
let sawRetry = false;
|
||||
let firstCallCommand: string | null = null;
|
||||
spawnMock.mockImplementation((cmd: string, args: string[]) => {
|
||||
if (args[0] === "call" && firstCallCommand === null) {
|
||||
firstCallCommand = cmd;
|
||||
}
|
||||
if (args[0] === "call" && typeof cmd === "string" && cmd.toLowerCase().endsWith(".cmd")) {
|
||||
const child = createMockChild({ autoClose: false });
|
||||
queueMicrotask(() => {
|
||||
@@ -1665,10 +1669,16 @@ describe("QmdMemoryManager", () => {
|
||||
await expect(
|
||||
manager.search("hello", { sessionKey: "agent:main:slack:dm:u123" }),
|
||||
).resolves.toEqual([]);
|
||||
expect(sawRetry).toBe(true);
|
||||
expect(logWarnMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining("retrying with bare mcporter"),
|
||||
);
|
||||
const attemptedCmdShim = (firstCallCommand ?? "").toLowerCase().endsWith(".cmd");
|
||||
if (attemptedCmdShim) {
|
||||
expect(sawRetry).toBe(true);
|
||||
expect(logWarnMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining("retrying with bare mcporter"),
|
||||
);
|
||||
} else {
|
||||
// When wrapper resolution upgrades to a direct node/exe entrypoint, cmd-shim retry is unnecessary.
|
||||
expect(sawRetry).toBe(false);
|
||||
}
|
||||
await manager.close();
|
||||
} finally {
|
||||
platformSpy.mockRestore();
|
||||
|
||||
Reference in New Issue
Block a user