diff --git a/test/docker-config.test.js b/test/docker-config.test.js index 991fd93..ab0503e 100644 --- a/test/docker-config.test.js +++ b/test/docker-config.test.js @@ -24,18 +24,20 @@ test("Docker Configuration: Dockerfile enforces Node runtime and excludes Nginx" assert.match(content, /CMD\s*\[\s*["']npm["']\s*,\s*["']start["']\s*\]/, "Dockerfile must start via npm start"); }); -test("Docker Configuration: docker-compose.yml configures Node service correctly", () => { - const composePath = path.resolve(process.cwd(), "docker-compose.yml"); - assert.ok(fs.existsSync(composePath), "docker-compose.yml must exist"); +test("Docker Configuration: docker-compose configures Node service correctly", () => { + const composePath = fs.existsSync(path.resolve(process.cwd(), "sample-docker-compose.yml")) + ? path.resolve(process.cwd(), "sample-docker-compose.yml") + : path.resolve(process.cwd(), "docker-compose.yml"); + assert.ok(fs.existsSync(composePath), "Compose template file must exist"); const content = fs.readFileSync(composePath, "utf-8"); // Verifies dynamic port mapping and environment variables - assert.match(content, /PORT:\s*\$\{PORT:-8080\}/, "docker-compose.yml must pass dynamic PORT build arg and env"); + assert.match(content, /PORT:\s*"?\$\{PORT:-8080\}"?/, "docker-compose.yml must pass dynamic PORT build arg and env"); assert.match(content, /:\$\{PORT:-8080\}/, "docker-compose.yml must map dynamic container PORT"); // Verifies healthcheck targets dynamic port - assert.match(content, /localhost:\$\{PORT:-8080\}\/healthz/, "Healthcheck must probe dynamic PORT on /healthz"); + assert.match(content, /(127\.0\.0\.1|localhost):\$\{PORT:-8080\}\/healthz/, "Healthcheck must probe dynamic PORT on /healthz"); // Verifies domain argument enforcement assert.match(content, /SITE_DOMAIN/, "docker-compose.yml must require SITE_DOMAIN");