fix: 修复 runner 迁移后的部署状态检查
This commit is contained in:
1 parent
ca6d1712bd
commit
12a3bf2f3b
6 files changed
+102
-38
No files matched your search
@@ -0,0 +1,32 @@
|
||||
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/);
|
||||
});
|
||||
|
||||
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/);
|
||||
});
|
||||
Reference in new issue
Block a user