mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-15 00:17:09 +00:00
feat(docker): add integrated deployment commands
- add ccs docker subcommands for up, down, status, update, logs, and config - bundle integrated docker assets and remote ssh deployment support - add executor regression tests and root help/router coverage Refs #812
This commit is contained in:
1 parent
48da0f3538
commit
23f767b0c5
29 files changed
+1607
No files matched your search
@@ -0,0 +1,107 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, mock } from 'bun:test';
|
||||
|
||||
let calls: string[] = [];
|
||||
let originalExitCode: number | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
calls = [];
|
||||
originalExitCode = process.exitCode;
|
||||
process.exitCode = 0;
|
||||
|
||||
mock.module('../../../src/commands/docker/help-subcommand', () => ({
|
||||
showHelp: async () => {
|
||||
calls.push('help');
|
||||
},
|
||||
}));
|
||||
|
||||
mock.module('../../../src/commands/docker/up-subcommand', () => ({
|
||||
handleUp: async (args: string[]) => {
|
||||
calls.push(`up:${args.join(' ')}`);
|
||||
},
|
||||
}));
|
||||
|
||||
mock.module('../../../src/commands/docker/down-subcommand', () => ({
|
||||
handleDown: async (args: string[]) => {
|
||||
calls.push(`down:${args.join(' ')}`);
|
||||
},
|
||||
}));
|
||||
|
||||
mock.module('../../../src/commands/docker/status-subcommand', () => ({
|
||||
handleStatus: async (args: string[]) => {
|
||||
calls.push(`status:${args.join(' ')}`);
|
||||
},
|
||||
}));
|
||||
|
||||
mock.module('../../../src/commands/docker/update-subcommand', () => ({
|
||||
handleUpdate: async (args: string[]) => {
|
||||
calls.push(`update:${args.join(' ')}`);
|
||||
},
|
||||
}));
|
||||
|
||||
mock.module('../../../src/commands/docker/logs-subcommand', () => ({
|
||||
handleLogs: async (args: string[]) => {
|
||||
calls.push(`logs:${args.join(' ')}`);
|
||||
},
|
||||
}));
|
||||
|
||||
mock.module('../../../src/commands/docker/config-subcommand', () => ({
|
||||
handleConfig: async (args: string[]) => {
|
||||
calls.push(`config:${args.join(' ')}`);
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
mock.restore();
|
||||
process.exitCode = originalExitCode ?? 0;
|
||||
});
|
||||
|
||||
async function loadHandleDockerCommand() {
|
||||
const mod = await import(`../../../src/commands/docker/index?test=${Date.now()}-${Math.random()}`);
|
||||
return mod.handleDockerCommand;
|
||||
}
|
||||
|
||||
describe('docker command', () => {
|
||||
it('shows help when invoked without a subcommand', async () => {
|
||||
const handleDockerCommand = await loadHandleDockerCommand();
|
||||
|
||||
await handleDockerCommand([]);
|
||||
|
||||
expect(calls).toEqual(['help']);
|
||||
expect(process.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
it('routes nested subcommands with remaining args intact', async () => {
|
||||
const handleDockerCommand = await loadHandleDockerCommand();
|
||||
|
||||
await handleDockerCommand(['up', '--host', 'my-box', '--port', '4000']);
|
||||
|
||||
expect(calls).toEqual(['up:--host my-box --port 4000']);
|
||||
});
|
||||
|
||||
it('supports --host before the subcommand', async () => {
|
||||
const handleDockerCommand = await loadHandleDockerCommand();
|
||||
|
||||
await handleDockerCommand(['--host', 'my-box', 'status']);
|
||||
|
||||
expect(calls).toEqual(['status:--host my-box']);
|
||||
});
|
||||
|
||||
it('treats help as a nested subcommand alias', async () => {
|
||||
const handleDockerCommand = await loadHandleDockerCommand();
|
||||
|
||||
await handleDockerCommand(['help']);
|
||||
|
||||
expect(calls).toEqual(['help']);
|
||||
expect(process.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
it('marks unknown subcommands as failures after printing help', async () => {
|
||||
const handleDockerCommand = await loadHandleDockerCommand();
|
||||
|
||||
await handleDockerCommand(['unknown']);
|
||||
|
||||
expect(calls).toEqual(['help']);
|
||||
expect(process.exitCode).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user