Przeglądaj źródła

fix(test): reset currentIndexName between test files

collections-config.test.ts set currentIndexName to "myindex" in its
last test but only restored env vars in afterEach — not the module
variable. Under bun test (single process), this leaked into mcp.test.ts,
causing it to look for myindex.yml instead of index.yml.

Fix: reset setConfigIndexName("index") in afterEach, and add defensive
reset in mcp.test.ts beforeAll.
Tobi Lutke 3 miesięcy temu
rodzic
commit
648779a04d
2 zmienionych plików z 6 dodań i 0 usunięć
  1. 2 0
      test/collections-config.test.ts
  2. 4 0
      test/mcp.test.ts

+ 2 - 0
test/collections-config.test.ts

@@ -23,6 +23,8 @@ beforeEach(() => {
 });
 
 afterEach(() => {
+  // Reset index name to default (prevents leaking into other test files under bun test)
+  setConfigIndexName("index");
   for (const [key, val] of Object.entries(savedEnv)) {
     if (val === undefined) {
       delete process.env[key];

+ 4 - 0
test/mcp.test.ts

@@ -16,6 +16,7 @@ import { join } from "node:path";
 import { tmpdir } from "node:os";
 import YAML from "yaml";
 import type { CollectionConfig } from "../src/collections";
+import { setConfigIndexName } from "../src/collections";
 
 // =============================================================================
 // Test Database Setup
@@ -206,6 +207,9 @@ describe("MCP Server", () => {
     // Use shared singleton to avoid creating multiple instances with separate GPU resources
     getDefaultLlamaCpp();
 
+    // Reset index name in case another test file mutated it (bun test shares process)
+    setConfigIndexName("index");
+
     // Set up test config directory
     const configPrefix = join(tmpdir(), `qmd-mcp-config-${Date.now()}-${Math.random().toString(36).slice(2)}`);
     testConfigDir = await mkdtemp(configPrefix);