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.
This commit is contained in:
parent
0697bc59d6
commit
648779a04d
@ -23,6 +23,8 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
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)) {
|
for (const [key, val] of Object.entries(savedEnv)) {
|
||||||
if (val === undefined) {
|
if (val === undefined) {
|
||||||
delete process.env[key];
|
delete process.env[key];
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import { join } from "node:path";
|
|||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import YAML from "yaml";
|
import YAML from "yaml";
|
||||||
import type { CollectionConfig } from "../src/collections";
|
import type { CollectionConfig } from "../src/collections";
|
||||||
|
import { setConfigIndexName } from "../src/collections";
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Test Database Setup
|
// Test Database Setup
|
||||||
@ -206,6 +207,9 @@ describe("MCP Server", () => {
|
|||||||
// Use shared singleton to avoid creating multiple instances with separate GPU resources
|
// Use shared singleton to avoid creating multiple instances with separate GPU resources
|
||||||
getDefaultLlamaCpp();
|
getDefaultLlamaCpp();
|
||||||
|
|
||||||
|
// Reset index name in case another test file mutated it (bun test shares process)
|
||||||
|
setConfigIndexName("index");
|
||||||
|
|
||||||
// Set up test config directory
|
// Set up test config directory
|
||||||
const configPrefix = join(tmpdir(), `qmd-mcp-config-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
const configPrefix = join(tmpdir(), `qmd-mcp-config-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
||||||
testConfigDir = await mkdtemp(configPrefix);
|
testConfigDir = await mkdtemp(configPrefix);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user