Files
TORCH/test/nostr-lock.test.mjs
T
google-labs-jules[bot]andPR0M3TH3AN 35092b3d5a Refactor torch-lock into an installable NPM library and CLI
- Rename `src/nostr-lock.mjs` to `src/lib.mjs` and export core functions.
- Create `bin/torch-lock.mjs` as the CLI entry point.
- Implement `dashboard` command in `src/lib.mjs` to serve the dashboard using Node.js.
- Update `package.json` to configure `bin`, `main`, and `files` for NPM packaging.
- Create `torch-config.example.json` as a template for consumers.
- Update tests and README.md to reflect the new structure.
- Exclude task-specific artifacts (logs, context) from the package while retaining prompts and docs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 06:41:49 +00:00

39 lines
1.3 KiB
JavaScript

import { test, describe, it } from 'node:test';
import assert from 'node:assert';
import { spawnSync } from 'node:child_process';
import fs from 'node:fs';
describe('CLI Smoke Test', () => {
it('should print usage when no args provided', () => {
const result = spawnSync('node', ['bin/torch-lock.mjs']);
assert.strictEqual(result.status, 1);
assert.match(result.stderr.toString(), /Usage:/);
});
it('should fail when checking without cadence', () => {
const result = spawnSync('node', ['bin/torch-lock.mjs', 'check']);
assert.strictEqual(result.status, 1);
assert.match(result.stderr.toString(), /--cadence <daily|weekly> is required/);
});
it('should include paused agents in check output', () => {
const configPath = 'test-torch-config.json';
fs.writeFileSync(configPath, JSON.stringify({
scheduler: { paused: { daily: ['paused-agent'] } }
}));
try {
const result = spawnSync('node', ['bin/torch-lock.mjs', 'check', '--cadence', 'daily'], {
env: { ...process.env, TORCH_CONFIG_PATH: configPath }
});
const output = JSON.parse(result.stdout.toString());
assert.deepStrictEqual(output.paused, ['paused-agent']);
assert.ok(output.excluded.includes('paused-agent'));
} finally {
if (fs.existsSync(configPath)) {
fs.unlinkSync(configPath);
}
}
});
});