MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / loadSchema

Function loadSchema

packages/language/test/utils.ts:10–21  ·  view source on GitHub ↗
(schema: string)

Source from the content-addressed store, hash-verified

8const pluginDocs = [path.resolve(__dirname, '../../plugins/policy/plugin.zmodel')];
9
10export async function loadSchema(schema: string) {
11 // create a temp file
12 const tempFile = path.join(os.tmpdir(), `zenstack-schema-${crypto.randomUUID()}.zmodel`);
13 fs.writeFileSync(tempFile, schema);
14 const r = await loadDocument(tempFile, pluginDocs);
15 expect(r).toSatisfy(
16 (r) => r.success,
17 `Failed to load schema: ${(r as any).errors?.map((e) => e.toString()).join(', ')}`,
18 );
19 invariant(r.success);
20 return r.model;
21}
22
23export async function loadSchemaWithError(schema: string, error: string | RegExp) {
24 // create a temp file

Calls 3

loadDocumentFunction · 0.90
invariantFunction · 0.90
toStringMethod · 0.45

Tested by

no test coverage detected