


























@@ -41,64 +41,54 @@ describe("registerBackupCommand", () => {
4141backupVerifyCommand.mockResolvedValue(undefined);
4242});
434344+function expectForwardedOptions(command: typeof backupCreateCommand): Record<string, unknown> {
45+expect(command).toHaveBeenCalledTimes(1);
46+const [runtimeArg, options] = command.mock.calls[0] as unknown as [
47+typeof runtime,
48+Record<string, unknown>,
49+];
50+expect(runtimeArg).toBe(runtime);
51+return options;
52+}
53+4454it("runs backup create with forwarded options", async () => {
4555await runCli(["backup", "create", "--output", "/tmp/backups", "--json", "--dry-run"]);
465647-expect(backupCreateCommand).toHaveBeenCalledWith(
48-runtime,
49-expect.objectContaining({
50-output: "/tmp/backups",
51-json: true,
52-dryRun: true,
53-verify: false,
54-onlyConfig: false,
55-includeWorkspace: true,
56-}),
57-);
57+const options = expectForwardedOptions(backupCreateCommand);
58+expect(options.output).toBe("/tmp/backups");
59+expect(options.json).toBe(true);
60+expect(options.dryRun).toBe(true);
61+expect(options.verify).toBe(false);
62+expect(options.onlyConfig).toBe(false);
63+expect(options.includeWorkspace).toBe(true);
5864});
59656066it("honors --no-include-workspace", async () => {
6167await runCli(["backup", "create", "--no-include-workspace"]);
626863-expect(backupCreateCommand).toHaveBeenCalledWith(
64-runtime,
65-expect.objectContaining({
66-includeWorkspace: false,
67-}),
68-);
69+const options = expectForwardedOptions(backupCreateCommand);
70+expect(options.includeWorkspace).toBe(false);
6971});
70727173it("forwards --verify to backup create", async () => {
7274await runCli(["backup", "create", "--verify"]);
737574-expect(backupCreateCommand).toHaveBeenCalledWith(
75-runtime,
76-expect.objectContaining({
77-verify: true,
78-}),
79-);
76+const options = expectForwardedOptions(backupCreateCommand);
77+expect(options.verify).toBe(true);
8078});
81798280it("forwards --only-config to backup create", async () => {
8381await runCli(["backup", "create", "--only-config"]);
848285-expect(backupCreateCommand).toHaveBeenCalledWith(
86-runtime,
87-expect.objectContaining({
88-onlyConfig: true,
89-}),
90-);
83+const options = expectForwardedOptions(backupCreateCommand);
84+expect(options.onlyConfig).toBe(true);
9185});
92869387it("runs backup verify with forwarded options", async () => {
9488await runCli(["backup", "verify", "/tmp/openclaw-backup.tar.gz", "--json"]);
958996-expect(backupVerifyCommand).toHaveBeenCalledWith(
97-runtime,
98-expect.objectContaining({
99-archive: "/tmp/openclaw-backup.tar.gz",
100-json: true,
101-}),
102-);
90+const options = expectForwardedOptions(backupVerifyCommand);
91+expect(options.archive).toBe("/tmp/openclaw-backup.tar.gz");
92+expect(options.json).toBe(true);
10393});
10494});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。