45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import type { CanonicalWorkspace, WorkspaceRevision, WorkspaceSummary } from "../api/workspaces";
|
|
|
|
export function canonicalWorkspaceFixture(
|
|
id: string,
|
|
_allowed: `${string}/${string}`[] = ["zai/glm-5.2"],
|
|
_defaultModel?: `${string}/${string}`,
|
|
): CanonicalWorkspace {
|
|
return {
|
|
workspace: { schema_version: 4, id, name: id, language: "en" },
|
|
dwh: {
|
|
engine: "postgres", database: "database", schema: "public",
|
|
supported_transports: ["postgres_direct"],
|
|
},
|
|
};
|
|
}
|
|
|
|
export function workspaceRevisionFixture(id: string): WorkspaceRevision {
|
|
return {
|
|
id, commit: "a".repeat(40), blob: "b".repeat(40),
|
|
snapshotPath: `/snapshots/${"a".repeat(40)}/${id}.yaml`,
|
|
};
|
|
}
|
|
|
|
export function workspaceSummaryFixture(
|
|
id: string,
|
|
options: {
|
|
displayName?: string;
|
|
description?: string;
|
|
configurationState?: WorkspaceSummary["configurationState"];
|
|
revision?: WorkspaceRevision;
|
|
} = {},
|
|
): WorkspaceSummary {
|
|
const configurationState = options.configurationState ?? "ready";
|
|
const revision = options.revision ?? (configurationState === "ready" ? workspaceRevisionFixture(id) : undefined);
|
|
return {
|
|
id,
|
|
name: id,
|
|
file: `${id}/workspace.yaml`,
|
|
displayName: options.displayName ?? id,
|
|
...(options.description === undefined ? {} : { description: options.description }),
|
|
configurationState,
|
|
...(revision ? { revision } : {}),
|
|
};
|
|
}
|