fix(backups): сохранять расписание и хранилище независимо
This commit is contained in:
1 parent
5ce21e9a47
commit
8e01666e0e
12 files changed
+286
-104
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { test } from "node:test"
|
||||
import { backupSchedulePayload } from "./backup-settings"
|
||||
const form = { enabled: false, frequency: "daily" as const, hour: "0", minute: "7", weekDay: 0, monthDay: 1, keepCount: "365", format: "rsc" as const }
|
||||
test("schedule preserves zero, arbitrary minute and explicit all-enabled semantics", () => {
|
||||
const result = backupSchedulePayload(form, ["1"], true)
|
||||
assert.equal(result.hour, 0); assert.equal(result.minute, 7); assert.equal(result.keepCount, 365); assert.deepEqual(result.serverIds, [])
|
||||
assert.deepEqual(backupSchedulePayload(form, ["1"], false).serverIds, ["1"])
|
||||
})
|
||||
test("blank, fractional, negative and out-of-range numbers are rejected without normalization", () => {
|
||||
for (const hour of ["", "1.5", "-1", "24", "1e1"]) assert.throws(() => backupSchedulePayload({ ...form, hour }, ["1"], false))
|
||||
assert.throws(() => backupSchedulePayload({ ...form, keepCount: "366" }, ["1"], false))
|
||||
assert.throws(() => backupSchedulePayload(form, [], false))
|
||||
})
|
||||
test("unsupported binary schedule requires an explicit format choice", () => {
|
||||
assert.throws(() => backupSchedulePayload({ ...form, enabled: true, format: "backup" }, ["1"], false))
|
||||
assert.equal(backupSchedulePayload({ ...form, format: "backup" }, ["1"], false).format, "backup")
|
||||
})
|
||||
Reference in new issue
Block a user