Files
wehub-resource-sync f9447f8e5f
CI / typecheck · build · test · bundle-size (push) Failing after 1s
CI / clean-room dependency closure smoke (push) Failing after 1s
CI / server-runtime e2e (docker · pg + valkey) (push) Failing after 2s
Deploy Install Scripts / deploy (push) Failing after 2s
Windows / build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:07:03 +08:00

69 lines
2.1 KiB
TypeScript

import { afterAll, afterEach, describe, expect, mock, test } from 'bun:test';
import { mkdtempSync, rmSync, writeFileSync } from 'fs';
import { join } from 'path';
import { tmpdir } from 'os';
import * as realPaths from '../../../src/shared/paths.js';
const realPathsSnapshot = { ...realPaths };
describe('redis queue config', () => {
const previousEnv = new Map<string, string | undefined>();
let tempDir: string | null = null;
afterEach(() => {
for (const [key, value] of previousEnv.entries()) {
if (value === undefined) {
delete process.env[key];
} else {
process.env[key] = value;
}
}
previousEnv.clear();
if (tempDir) {
rmSync(tempDir, { recursive: true, force: true });
tempDir = null;
}
mock.restore();
});
afterAll(() => {
mock.module('../../../src/shared/paths.js', () => realPathsSnapshot);
});
test('loads queue settings from settings file with env override precedence', async () => {
tempDir = mkdtempSync(join(tmpdir(), 'claude-mem-redis-config-'));
const settingsPath = join(tempDir, 'settings.json');
writeFileSync(settingsPath, JSON.stringify({
CLAUDE_MEM_QUEUE_ENGINE: 'bullmq',
CLAUDE_MEM_REDIS_MODE: 'external',
CLAUDE_MEM_REDIS_HOST: 'settings-host',
CLAUDE_MEM_REDIS_PORT: '6381',
CLAUDE_MEM_REDIS_URL: '',
CLAUDE_MEM_QUEUE_REDIS_PREFIX: 'settings-prefix',
}), 'utf-8');
mock.module('../../../src/shared/paths.js', () => ({
...realPathsSnapshot,
paths: realPaths.paths,
USER_SETTINGS_PATH: settingsPath,
}));
setEnv('CLAUDE_MEM_REDIS_HOST', 'env-host');
const { getRedisQueueConfig, getObservationQueueEngineName } = await import('../../../src/server/queue/redis-config.js');
expect(getObservationQueueEngineName()).toBe('bullmq');
const config = getRedisQueueConfig();
expect(config.host).toBe('env-host');
expect(config.port).toBe(6381);
expect(config.prefix).toBe('settings-prefix');
});
function setEnv(key: string, value: string): void {
if (!previousEnv.has(key)) {
previousEnv.set(key, process.env[key]);
}
process.env[key] = value;
}
});