test: require command helper results

This commit is contained in:
Peter Steinberger
2026-05-08 17:12:21 +01:00
parent 2d5a5ee666
commit de850f44f5
4 changed files with 13 additions and 6 deletions

View File

@@ -276,8 +276,7 @@ describe("agents delete command", () => {
await agentsDeleteCommand({ id: "ops", force: true, json: true }, runtime);
// Workspace should still exist — it was shared
const stat = await fs.stat(sharedWorkspace).catch(() => null);
expect(stat).not.toBeNull();
await expect(fs.stat(sharedWorkspace)).resolves.toEqual(expect.any(Object));
// The JSON output should report why the workspace was retained.
const jsonOutput = readJsonLogs();

View File

@@ -210,6 +210,8 @@ describe("backup commands", () => {
expect(result.archivePath).toBe(
path.join(backupDir, `${buildBackupArchiveRoot(nowMs)}.tar.gz`),
);
expect(capturedManifest).toEqual(expect.objectContaining({ assets: expect.any(Array) }));
expect(capturedOnWriteEntry).toEqual(expect.any(Function));
if (capturedManifest === null || capturedOnWriteEntry === null) {
throw new Error("Expected backup manifest and archive entry callback");
}

View File

@@ -115,8 +115,11 @@ describe("detectLinuxSdBackedStateDir", () => {
},
});
expect(result).not.toBeNull();
const warning = formatLinuxSdBackedStateDirWarning(stateDir, result!);
expect(result).toEqual(expect.any(Object));
if (result === null) {
throw new Error("Expected Linux state storage warning details");
}
const warning = formatLinuxSdBackedStateDirWarning(stateDir, result);
expect(warning).toContain("device /dev/disk/by-uuid/mmc\\nsource");
expect(warning).toContain("mount /home/pi/mnt\\nspoofed");
expect(warning).not.toContain("device /dev/disk/by-uuid/mmc\nsource");

View File

@@ -656,8 +656,11 @@ describe("legacy migrate heartbeat config", () => {
});
expect(res.changes).toContain("Removed empty top-level heartbeat.");
expect(res.config).not.toBeNull();
expect((res.config as { heartbeat?: unknown } | null)?.heartbeat).toBeUndefined();
expect(res.config).toEqual(expect.any(Object));
if (res.config === null) {
throw new Error("Expected migrated config");
}
expect((res.config as { heartbeat?: unknown }).heartbeat).toBeUndefined();
});
});