Files
thedotmack--claude-mem/tests/npx-cli-server-namespace.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

54 lines
2.9 KiB
TypeScript

import { describe, expect, it } from 'bun:test';
import { readFileSync } from 'fs';
import { join } from 'path';
const indexSource = readFileSync(join(__dirname, '..', 'src', 'npx-cli', 'index.ts'), 'utf-8');
const serverSource = readFileSync(join(__dirname, '..', 'src', 'npx-cli', 'commands', 'server.ts'), 'utf-8');
const workerServiceSource = readFileSync(join(__dirname, '..', 'src', 'services', 'worker-service.ts'), 'utf-8');
describe('npx CLI server namespace', () => {
it('routes the server namespace through the server command module', () => {
expect(indexSource).toContain("case 'server'");
expect(indexSource).toContain("await import('./commands/server.js')");
expect(indexSource).toContain('await runServerCommand(args.slice(1))');
});
it('routes worker lifecycle aliases through the server command module', () => {
expect(indexSource).toContain("case 'worker'");
expect(indexSource).toContain('runWorkerAliasCommand(args.slice(1))');
expect(serverSource).toContain('runWorkerLifecycleCommand');
expect(serverSource).toContain('runStartCommand()');
expect(serverSource).toContain('runStopCommand()');
expect(serverSource).toContain('runRestartCommand()');
expect(serverSource).toContain('runStatusCommand()');
});
it('routes server lifecycle commands and falls through to a nonzero failure for unknown commands', () => {
expect(serverSource).toContain('runServerLifecycleCommand(subCommand)');
expect(serverSource).toContain('runServerStartCommand()');
expect(serverSource).toContain('runServerStopCommand()');
expect(serverSource).toContain('runServerRestartCommand()');
expect(serverSource).toContain('runServerStatusCommand()');
expect(serverSource).toContain("process.exit(1)");
expect(serverSource).toContain('runServerApiKeyCommand(argv.slice(1))');
expect(serverSource).not.toContain('runServerLogsCommand');
expect(serverSource).not.toContain("'logs'");
expect(serverSource).not.toContain("'doctor'");
expect(serverSource).not.toContain("'migrate'");
});
it('normalizes direct worker-service server invocations', () => {
expect(workerServiceSource).toContain("rawCommand === 'server'");
expect(workerServiceSource).toContain('lifecycleCommands.has(maybeSubCommand)');
expect(workerServiceSource).toContain('command: `server-${maybeSubCommand}`');
expect(workerServiceSource).toContain("case 'server-start'");
expect(workerServiceSource).toContain('runServerServiceCli(command.slice');
expect(workerServiceSource).toContain('serverCommands.has(maybeSubCommand)');
expect(workerServiceSource).toContain("case 'server-api-key'");
expect(workerServiceSource).toContain('runServerApiKeyCli(commandArgs)');
expect(workerServiceSource).toContain("case 'server-help'");
expect(workerServiceSource).toContain("case 'worker-help'");
expect(workerServiceSource).not.toContain('command: maybeSubCommand ??');
});
});