mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 15:18:28 +00:00
perf(test): mock chokidar in memory tests
This commit is contained in:
@@ -6,6 +6,14 @@ import { getMemorySearchManager, type MemoryIndexManager } from "./index.js";
|
|||||||
|
|
||||||
let embedBatchCalls = 0;
|
let embedBatchCalls = 0;
|
||||||
|
|
||||||
|
// Unit tests: avoid importing the real chokidar implementation (native fsevents, etc.).
|
||||||
|
vi.mock("chokidar", () => ({
|
||||||
|
default: {
|
||||||
|
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||||
|
},
|
||||||
|
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||||
|
}));
|
||||||
|
|
||||||
vi.mock("./sqlite-vec.js", () => ({
|
vi.mock("./sqlite-vec.js", () => ({
|
||||||
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ import { getMemorySearchManager, type MemoryIndexManager } from "./index.js";
|
|||||||
const embedBatch = vi.fn(async () => []);
|
const embedBatch = vi.fn(async () => []);
|
||||||
const embedQuery = vi.fn(async () => [0.5, 0.5, 0.5]);
|
const embedQuery = vi.fn(async () => [0.5, 0.5, 0.5]);
|
||||||
|
|
||||||
|
// Unit tests: avoid importing the real chokidar implementation (native fsevents, etc.).
|
||||||
|
vi.mock("chokidar", () => ({
|
||||||
|
default: {
|
||||||
|
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||||
|
},
|
||||||
|
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||||
|
}));
|
||||||
|
|
||||||
vi.mock("./sqlite-vec.js", () => ({
|
vi.mock("./sqlite-vec.js", () => ({
|
||||||
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ import { getMemorySearchManager, type MemoryIndexManager } from "./index.js";
|
|||||||
const embedBatch = vi.fn(async (texts: string[]) => texts.map(() => [0, 1, 0]));
|
const embedBatch = vi.fn(async (texts: string[]) => texts.map(() => [0, 1, 0]));
|
||||||
const embedQuery = vi.fn(async () => [0, 1, 0]);
|
const embedQuery = vi.fn(async () => [0, 1, 0]);
|
||||||
|
|
||||||
|
// Unit tests: avoid importing the real chokidar implementation (native fsevents, etc.).
|
||||||
|
vi.mock("chokidar", () => ({
|
||||||
|
default: {
|
||||||
|
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||||
|
},
|
||||||
|
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||||
|
}));
|
||||||
|
|
||||||
vi.mock("./sqlite-vec.js", () => ({
|
vi.mock("./sqlite-vec.js", () => ({
|
||||||
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ import { getMemorySearchManager, type MemoryIndexManager } from "./index.js";
|
|||||||
const embedBatch = vi.fn(async (texts: string[]) => texts.map(() => [0, 1, 0]));
|
const embedBatch = vi.fn(async (texts: string[]) => texts.map(() => [0, 1, 0]));
|
||||||
const embedQuery = vi.fn(async () => [0, 1, 0]);
|
const embedQuery = vi.fn(async () => [0, 1, 0]);
|
||||||
|
|
||||||
|
// Unit tests: avoid importing the real chokidar implementation (native fsevents, etc.).
|
||||||
|
vi.mock("chokidar", () => ({
|
||||||
|
default: {
|
||||||
|
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||||
|
},
|
||||||
|
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||||
|
}));
|
||||||
|
|
||||||
vi.mock("./sqlite-vec.js", () => ({
|
vi.mock("./sqlite-vec.js", () => ({
|
||||||
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user