zerobyte/app/server/utils/restic/helpers/__tests__/validate-custom-params.test.ts
Nicolas Meienberger c2ed9e3693
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / checks (push) Has been cancelled
Release Workflow / e2e-tests (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
refactor: correctly delete orphan sessions after idp deletion
2026-03-05 21:02:56 +01:00

44 lines
1.4 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import { validateCustomResticParams } from "../validate-custom-params";
describe("validateCustomResticParams", () => {
test("accepts supported flags and values", () => {
const result = validateCustomResticParams([
"--no-scan",
"--read-concurrency 8",
"--exclude-larger-than 500M",
"--pack-size=64",
]);
expect(result).toBeNull();
});
test("rejects positional arguments", () => {
const result = validateCustomResticParams(["/etc"]);
expect(result).toContain('Unexpected positional argument "/etc"');
});
test("rejects extra positional arguments after a flag value", () => {
const result = validateCustomResticParams(["--read-concurrency 8 /etc"]);
expect(result).toContain('Unexpected positional argument "/etc"');
});
test("rejects unsupported path-bearing flags", () => {
const result = validateCustomResticParams(["--cache-dir /tmp/restic-cache"]);
expect(result).toContain('Unknown or unsupported flag "--cache-dir"');
});
test("rejects dry-run flags", () => {
expect(validateCustomResticParams(["--dry-run"])).toContain('Unknown or unsupported flag "--dry-run"');
expect(validateCustomResticParams(["-n"])).toContain('Unknown or unsupported flag "-n"');
});
test("rejects missing values for flags that require one", () => {
const result = validateCustomResticParams(["--read-concurrency"]);
expect(result).toBe('Flag "--read-concurrency" requires a value');
});
});