Files
thedotmack--claude-mem/tests/server/server-runtime-guard.test.ts
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

59 lines
2.1 KiB
TypeScript

// SPDX-License-Identifier: Apache-2.0
//
// #2572 — wrong-runtime guard for the server operability CLI.
// #2554 — stale DEFAULT_MODEL fix.
import { describe, expect, it } from 'bun:test';
import { assertServerRuntimeForCli } from '../../src/server/runtime/ServerService.js';
import { DEFAULT_SERVER_CLAUDE_MODEL } from '../../src/server/generation/providers/ClaudeObservationProvider.js';
describe('assertServerRuntimeForCli — wrong-runtime guard (#2572)', () => {
it('passes for canonical server runtime with a database URL', () => {
expect(() =>
assertServerRuntimeForCli('keys', {
CLAUDE_MEM_RUNTIME: 'server',
CLAUDE_MEM_SERVER_DATABASE_URL: 'postgres://localhost/db',
}),
).not.toThrow();
});
it('passes for legacy server-beta runtime literal (Phase 1d back-compat)', () => {
expect(() =>
assertServerRuntimeForCli('keys', {
CLAUDE_MEM_RUNTIME: 'server-beta',
CLAUDE_MEM_SERVER_DATABASE_URL: 'postgres://localhost/db',
}),
).not.toThrow();
});
it('passes when runtime is unset but a database URL is present (bare server image)', () => {
expect(() =>
assertServerRuntimeForCli('jobs', {
CLAUDE_MEM_SERVER_DATABASE_URL: 'postgres://localhost/db',
}),
).not.toThrow();
});
it('fails CLEARLY when run in a worker-only runtime context', () => {
expect(() =>
assertServerRuntimeForCli('keys', {
CLAUDE_MEM_RUNTIME: 'worker',
CLAUDE_MEM_SERVER_DATABASE_URL: 'postgres://localhost/db',
}),
).toThrow(/server runtime command.*CLAUDE_MEM_RUNTIME=worker/s);
});
it('fails CLEARLY (actionable) when no database URL is configured', () => {
expect(() =>
assertServerRuntimeForCli('jobs', { CLAUDE_MEM_RUNTIME: 'server' }),
).toThrow(/CLAUDE_MEM_SERVER_DATABASE_URL is required/);
});
});
describe('Claude provider default model (#2554)', () => {
it('uses a current, valid model id (not the stale claude-3-5-sonnet-latest)', () => {
expect(DEFAULT_SERVER_CLAUDE_MODEL).toBe('claude-sonnet-4-6');
expect(DEFAULT_SERVER_CLAUDE_MODEL).not.toBe('claude-3-5-sonnet-latest');
});
});