import { afterEach, expect, test } from "bun:test"; import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { runtimeGitopsScriptsConfigMap } from "./runtime-gitops-scripts-configmap.mjs"; const roots: string[] = []; afterEach(() => { while (roots.length > 0) rmSync(roots.pop()!, { recursive: true, force: true }); }); test("preserves codeAgentRuntime in the owning runtime GitOps overlay", () => { const scriptsDir = mkdtempSync(join(tmpdir(), "runtime-gitops-configmap-")); roots.push(scriptsDir); for (const name of ["runtime-gitops-observability.mjs", "runtime-gitops-postprocess.mjs", "runtime-gitops-verify.mjs"]) { writeFileSync(join(scriptsDir, name), `${name}\n`); } const codeAgentRuntime = { enabled: true, kafkaEventBridge: { enabled: true, features: { directPublish: false, liveKafkaSse: false, kafkaRefreshReplay: false, transactionalProjector: true, projectionOutboxRelay: true, projectionRealtime: true, }, }, }; const configMap = runtimeGitopsScriptsConfigMap({ overlay: { runtimePath: "runtime", observability: { prometheusOperator: false }, codeAgentRuntime }, scriptsDir, namespace: "hwlab", configMapName: "runtime-gitops-scripts", }); expect(JSON.parse(configMap.data["runtime-gitops-overlay.json"])).toEqual({ runtimePath: "runtime", observability: { prometheusOperator: false }, codeAgentRuntime, }); });