Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions test/config.test.js
Original file line number Diff line number Diff line change
@@ -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
);
});
Loading