Initial commit: DashCaddy v1.0

Full codebase including API server (32 modules + routes), dashboard frontend,
DashCA certificate distribution, installer script, and deployment skills.
This commit is contained in:
2026-03-05 02:26:12 -08:00
commit f61e85d9a7
337 changed files with 75282 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
/**
* Container Log Route Tests
*
* Tests Docker container log listing and retrieval endpoints
* Note: These tests run against the real Docker socket if available,
* or will gracefully handle Docker being unavailable in CI.
*/
const request = require('supertest');
const fs = require('fs');
const path = require('path');
const os = require('os');
const testServicesFile = path.join(os.tmpdir(), `logs-services-${Date.now()}.json`);
const testConfigFile = path.join(os.tmpdir(), `logs-config-${Date.now()}.json`);
process.env.SERVICES_FILE = testServicesFile;
process.env.CONFIG_FILE = testConfigFile;
process.env.ENABLE_HEALTH_CHECKER = 'false';
process.env.NODE_ENV = 'test';
fs.writeFileSync(testServicesFile, '[]', 'utf8');
fs.writeFileSync(testConfigFile, '{}', 'utf8');
const app = require('../server');
describe('Container Log Routes', () => {
afterAll(() => {
try { fs.unlinkSync(testServicesFile); } catch (e) { /* ignore */ }
try { fs.unlinkSync(testConfigFile); } catch (e) { /* ignore */ }
});
describe('GET /api/logs/containers', () => {
test('should return 200 with containers array', async () => {
const res = await request(app).get('/api/logs/containers');
expect(res.statusCode).toBe(200);
expect(res.body.success).toBe(true);
expect(Array.isArray(res.body.containers)).toBe(true);
});
});
describe('GET /api/logs/container/:id', () => {
test('should return 404 or 500 for nonexistent container', async () => {
const res = await request(app).get('/api/logs/container/nonexistent');
// Docker will throw a not-found error for an invalid container ID
expect([404, 500]).toContain(res.statusCode);
});
});
});