mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-19 12:16:10 +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,75 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, mock } from 'bun:test';
|
||||
|
||||
let logLines: string[] = [];
|
||||
let errorLines: string[] = [];
|
||||
let originalConsoleLog: typeof console.log;
|
||||
let originalConsoleError: typeof console.error;
|
||||
let originalExitCode: number | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
logLines = [];
|
||||
errorLines = [];
|
||||
originalConsoleLog = console.log;
|
||||
originalConsoleError = console.error;
|
||||
originalExitCode = process.exitCode;
|
||||
process.exitCode = 0;
|
||||
|
||||
console.log = (...args: unknown[]) => {
|
||||
logLines.push(args.map(String).join(' '));
|
||||
};
|
||||
console.error = (...args: unknown[]) => {
|
||||
errorLines.push(args.map(String).join(' '));
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
console.log = originalConsoleLog;
|
||||
console.error = originalConsoleError;
|
||||
process.exitCode = originalExitCode ?? 0;
|
||||
mock.restore();
|
||||
});
|
||||
|
||||
async function loadHandleStatus() {
|
||||
const mod = await import(
|
||||
`../../../src/commands/docker/status-subcommand?test=${Date.now()}-${Math.random()}`
|
||||
);
|
||||
return mod.handleStatus;
|
||||
}
|
||||
|
||||
describe('docker status subcommand', () => {
|
||||
it('prints supervisor failure details instead of masking them as a missing container', async () => {
|
||||
mock.module('../../../src/docker', () => ({
|
||||
DockerExecutor: class {
|
||||
async status() {
|
||||
return {
|
||||
compose: {
|
||||
command: '',
|
||||
exitCode: 0,
|
||||
stdout: 'NAME STATUS',
|
||||
stderr: '',
|
||||
remote: false,
|
||||
},
|
||||
supervisor: {
|
||||
command: '',
|
||||
exitCode: 7,
|
||||
stdout: '',
|
||||
stderr: 'unix:///var/run/supervisor.sock no such file',
|
||||
remote: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
const handleStatus = await loadHandleStatus();
|
||||
await handleStatus([]);
|
||||
|
||||
const rendered = logLines.join('\n');
|
||||
expect(rendered).toContain('Docker status');
|
||||
expect(rendered).toContain('Supervisor status check failed');
|
||||
expect(rendered).toContain('supervisor.sock no such file');
|
||||
expect(rendered).not.toContain('may not be running');
|
||||
expect(errorLines).toEqual([]);
|
||||
expect(process.exitCode).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user