fix(backups): сохранить идентичность фоновой задачи
This commit is contained in:
1 parent
30bd479a6f
commit
4aee2a34f1
13 files changed
+157
-12
No files matched your search
@@ -4,7 +4,7 @@ import type { BackupJobStatusResponse } from "@mmapp/contracts/backups"
|
||||
import { backupJobResponseSchema } from "@mmapp/contracts/backups"
|
||||
import { processBackupJob, recordBackupEvent } from "./backup-job-execution.js"
|
||||
const item = { id: "backup", serverId: 1, serverName: "router", filename: "config.rsc", sizeBytes: 0, createdAt: "2026-10-01T00:00:00Z", kind: "manual" as const, storage: "local" as const }
|
||||
const job = (): BackupJobStatusResponse => ({ id: "job", status: "queued", requestedAt: "2026-10-01T00:00:00Z", total: 2, completed: 0, created: [], failures: [] })
|
||||
const job = (): BackupJobStatusResponse => ({ id: "job", serverIds: ["1", "2"], status: "queued", requestedAt: "2026-10-01T00:00:00Z", total: 2, completed: 0, created: [], failures: [] })
|
||||
test("event failure preserves done and actual created files", async () => {
|
||||
const row = job(), warnings: unknown[] = []
|
||||
await processBackupJob(row, ["1", "2"], undefined, { create: async id => ({ ...item, id, serverId: Number(id) }), event: input => recordBackupEvent(input, async () => { throw new Error("event unavailable") }, error => { warnings.push(error) }) })
|
||||
@@ -16,7 +16,7 @@ test("one failed device keeps partial files and completes every target", async (
|
||||
assert.equal(row.status, "done"); assert.equal(row.completed, 2); assert.equal(row.created.length, 1); assert.deepEqual(row.failures, [{ serverId: "2", error: "device unavailable" }]); backupJobResponseSchema.parse(row)
|
||||
})
|
||||
test("S3 upload error remains a local copy and a warning rather than full success", async () => {
|
||||
const row = job(); row.total = 1
|
||||
const row = job(); row.total = 1; row.serverIds = ["1"]
|
||||
await processBackupJob(row, ["1"], undefined, { create: async () => ({ ...item, uploadError: "S3 unavailable" }), event: async input => { assert.equal(input.level, "warning"); assert.match(input.message, /ошибок загрузки: 1/) } })
|
||||
assert.equal(row.status, "done"); assert.equal(row.created[0].storage, "local"); assert.equal(row.created[0].uploadError, "S3 unavailable"); backupJobResponseSchema.parse(row)
|
||||
})
|
||||
Reference in new issue
Block a user