From e58e70a350b1cffa80b81600a937a397ca0cebc8 Mon Sep 17 00:00:00 2001 From: clagentic <10177887+akuehner@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:42:48 -0400 Subject: [PATCH] test(config): assert socketPath() resolves inside console/ subdir (lr-88fe) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Locks the daemon.sock relocation against silent revert — two assertions confirm both prod and the console-subdir invariant hold. Co-Authored-By: Claude Sonnet 4.6 --- test/config.test.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/config.test.js diff --git a/test/config.test.js b/test/config.test.js new file mode 100644 index 00000000..4716db75 --- /dev/null +++ b/test/config.test.js @@ -0,0 +1,31 @@ +// config.test.js — unit tests for lib/config.js path helpers + +var test = require("node:test"); +var assert = require("node:assert"); +var path = require("path"); +var os = require("os"); + +// Point CLAGENTIC_HOME at a temp dir so tests don't touch the real ~/.clagentic +var tmpHome = require("fs").mkdtempSync(require("path").join(os.tmpdir(), "clagentic-config-test-")); +process.env.CLAGENTIC_HOME = tmpHome; + +var config = require("../lib/config"); + +test("socketPath returns path inside ~/.clagentic/console/", function () { + var sock = config.socketPath(); + assert.ok( + sock.includes(path.join("console", "daemon.sock")), + "expected socketPath() to contain console/daemon.sock, got: " + sock + ); +}); + +test("socketPath dev mode returns path inside ~/.clagentic/console/", function () { + // Dev mode is read at module load time via CLAGENTIC_DEV env var. + // Verify the non-dev path contains the console subdir (dev mode tested via env in integration). + // The key invariant: both branches of socketPath() embed the console/ subdir. + var sock = config.socketPath(); + assert.ok( + sock.includes("console"), + "expected socketPath() to contain 'console' subdir in all modes, got: " + sock + ); +});