1a88ab3199
The v0.8 milestone: installable on any Debian-based server via docker (Gitea registry image, honest sandbox degrade), deb (amd64+arm64, advisory postinst), and arch-aware binary — with release consistency enforced by pre-commit hooks + Gitea Actions (3-runner fleet on CT 113, machine-made releases with the full 8-asset matrix + registry image), the CLI carrying the full suite (guide, channel-aware doctor), and the admin runbook (deploy/README.md, evidence-backed recipes). ---ci--- phase: 6 milestone: v0.8 status: complete requirements: covered: [REQ-8-001, REQ-8-002, REQ-8-003, REQ-8-004, REQ-8-005] partial: [] ---/ci---
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { compareVersions } from "../src/checks/check-command.ts";
|
|
import { parseEnvKeys, diffEnvTemplate } from "../src/checks/check-env.ts";
|
|
|
|
test("compareVersions: equal across patch omission", () => {
|
|
assert.equal(compareVersions("18.0.0", "18"), 0);
|
|
assert.equal(compareVersions("18", "18.0.0"), 0);
|
|
});
|
|
|
|
test("compareVersions: minor boundary", () => {
|
|
assert.equal(compareVersions("3.11", "3.11.2"), 0);
|
|
assert.equal(compareVersions("3.10", "3.11"), -1);
|
|
assert.equal(compareVersions("3.12", "3.11"), 1);
|
|
});
|
|
|
|
test("compareVersions: v-prefix and embedded version strings", () => {
|
|
assert.ok(compareVersions("v18.2.0", "18") >= 0);
|
|
assert.equal(compareVersions("Python 3.11.2", "3.11"), 0);
|
|
assert.ok(compareVersions("python3 (3.9)", "3.11") < 0);
|
|
});
|
|
|
|
test("compareVersions: major win beats minor", () => {
|
|
assert.equal(compareVersions("24.0.0", "18.99"), 1);
|
|
assert.equal(compareVersions("2.99", "18.0"), -1);
|
|
});
|
|
|
|
test("parseEnvKeys: skips comments and blanks", () => {
|
|
const content = [
|
|
"# comment",
|
|
"",
|
|
"AI_PORT=8420",
|
|
" AI_MODEL=gemma4:31b",
|
|
"#AI_SKIP=1",
|
|
"AI_OLLAMA_CLOUD_API_KEY=",
|
|
].join("\n");
|
|
assert.deepEqual(parseEnvKeys(content), ["AI_PORT", "AI_MODEL", "AI_OLLAMA_CLOUD_API_KEY"]);
|
|
});
|
|
|
|
test("diffEnvTemplate: missing + extra classification", () => {
|
|
const template = "A=1\nB=2\nC=3\n";
|
|
const env = "B=2\nD=4\n";
|
|
const diff = diffEnvTemplate(template, env);
|
|
assert.deepEqual(diff.missing, ["A", "C"]);
|
|
assert.deepEqual(diff.extra, ["D"]);
|
|
});
|
|
|
|
test("diffEnvTemplate: full coverage yields empty diff", () => {
|
|
const template = "A=1\nB=2\n";
|
|
const env = "A=x\nB=y\n";
|
|
const diff = diffEnvTemplate(template, env);
|
|
assert.deepEqual(diff.missing, []);
|
|
assert.deepEqual(diff.extra, []);
|
|
});
|