All checks were successful
Deploy MineGeo to Dokploy / deploy (push) Successful in 5m17s
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import {
|
|
deploymentState,
|
|
knownDeploymentIds,
|
|
retryableStatusPoll,
|
|
} from "../scripts/dokploy-deployment-state.mjs";
|
|
|
|
test("deployment monitoring cannot mistake any older successful build for the new upload", () => {
|
|
const baseline = [
|
|
{ id: "previous", status: "done" },
|
|
{ deploymentId: "older", status: "done" },
|
|
];
|
|
const ids = knownDeploymentIds({ deployments: baseline });
|
|
assert.equal(deploymentState(baseline, ids), "waiting");
|
|
assert.equal(deploymentState({ data: [baseline[1]] }, ids), "waiting");
|
|
assert.equal(
|
|
deploymentState([{ id: "new", status: "running" }, ...baseline], ids),
|
|
"running",
|
|
);
|
|
assert.equal(
|
|
deploymentState([{ id: "new", status: "done" }, ...baseline], ids),
|
|
"done",
|
|
);
|
|
assert.equal(
|
|
deploymentState([{ id: "new", status: "error" }, ...baseline], ids),
|
|
"error",
|
|
);
|
|
assert.equal(
|
|
deploymentState([{ id: "new", status: "cancelled" }], ids),
|
|
"cancelled",
|
|
);
|
|
});
|
|
|
|
test("deployment monitoring rejects malformed responses and baselines", () => {
|
|
assert.throws(() => knownDeploymentIds({ error: "Unauthorized" }));
|
|
assert.throws(() => deploymentState([null], []));
|
|
assert.throws(() => deploymentState([], "previous"));
|
|
assert.equal(
|
|
deploymentState([{ id: "first", status: "new-status" }], []),
|
|
"unknown",
|
|
);
|
|
});
|
|
|
|
test("only bounded transient read-only status failures retry; auth and TLS verification errors stop", () => {
|
|
for (const exit of [7, 28, 52, 55, 56])
|
|
assert.equal(retryableStatusPoll(exit, 0, 1), true);
|
|
for (const code of [408, 429, 500, 502, 503, 504])
|
|
assert.equal(retryableStatusPoll(0, code, 6), true);
|
|
for (const code of [400, 401, 403, 404])
|
|
assert.equal(retryableStatusPoll(0, code, 1), false);
|
|
assert.equal(retryableStatusPoll(60, 0, 1), false);
|
|
assert.equal(retryableStatusPoll(28, 0, 7), false);
|
|
});
|