fix(backups): сохранить идентичность фоновой задачи
This commit is contained in:
1 parent
30bd479a6f
commit
4aee2a34f1
13 files changed
+157
-12
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { test } from "node:test"
|
||||
import { backupJobCheckpointSchema, createBackupJobCheckpoint, readBackupJobCheckpoint, backupJobStorageKey } from "./backup-job-checkpoint"
|
||||
const id = "11111111-1111-4111-8111-111111111111"
|
||||
test("checkpoint freezes a canonical request before acknowledgment", () => {
|
||||
const ids = ["1", "2"], saved = createBackupJobCheckpoint({ serverIds: ids, notes: " manual " }, id); ids.push("3")
|
||||
assert.deepEqual(saved.request.serverIds, ["1", "2"]); assert.equal(saved.request.notes, "manual"); assert.equal(saved.accepted, false); assert.deepEqual(readBackupJobCheckpoint(JSON.stringify(saved)), saved)
|
||||
})
|
||||
test("corrupt or foreign checkpoints cannot be restored", () => {
|
||||
assert.throws(() => readBackupJobCheckpoint("bad")); assert.throws(() => createBackupJobCheckpoint({ serverIds: ["1", "1"] }, id))
|
||||
const saved = createBackupJobCheckpoint({ serverIds: ["1"] }, id)
|
||||
const job = { id: "other", status: "queued", serverIds: ["1"], total: 1, completed: 0, requestedAt: "2026-10-01T00:00:00Z", created: [], failures: [] }
|
||||
assert.equal(backupJobCheckpointSchema.safeParse({ ...saved, accepted: true, job }).success, false)
|
||||
})
|
||||
test("storage keys preserve backend scope and absent storage stays absent", () => {
|
||||
assert.notEqual(backupJobStorageKey("one"), backupJobStorageKey("two")); assert.equal(readBackupJobCheckpoint(null), null)
|
||||
})
|
||||
Reference in new issue
Block a user