Files
persionalBrand/scripts/deploy/status.test.mjs
que01 92227e1311
CI / API integration (pull_request) Successful in 1m44s
CI / Browser smoke (pull_request) Failing after 12m12s
CI / Static checks (pull_request) Failing after 12m13s
CI / Production build (pull_request) Has been cancelled
fix: 增加微信登录配置部署检查
2026-10-23 19:27:44 +08:00

38 lines
1.3 KiB
JavaScript

import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import test from "node:test";
import { buildRemoteStatusScript } from "./status.mjs";
test("生产状态脚本不再要求 VPS 上运行 CI runner", () => {
const script = buildRemoteStatusScript();
assert.doesNotMatch(script, /gitea-runner/);
assert.match(script, /pm2 pid personal-brand-api/);
assert.match(script, /pg_restore -l/);
assert.match(script, /personal-brand-backup\.timer/);
assert.match(script, /backup-age-hours/);
assert.match(script, /BACKUP_MAX_AGE_HOURS/);
assert.match(script, /wechat-login/);
assert.match(script, /WECHAT_APP_SECRET/);
});
test("生产状态脚本语法有效", () => {
const result = spawnSync("bash", ["-n"], {
input: buildRemoteStatusScript(),
encoding: "utf8",
});
assert.equal(result.status, 0, result.stderr);
});
test("生产状态脚本使用调用方指定的部署目录", () => {
const script = buildRemoteStatusScript({ deployRoot: "/srv/personal-brand" });
assert.match(script, /DEPLOY_ROOT='\/srv\/personal-brand'/);
assert.match(script, /"\$DEPLOY_ROOT\/current"/);
});
test("非法部署目录会被拒绝", () => {
assert.throws(() => buildRemoteStatusScript({ deployRoot: "/srv/personal brand" }), /Invalid/);
});