Skip to content

Commit

Permalink
Merge branch 'main' into met-799-clear-out-cached-typegraphs-on-boot
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-0acf4 authored Jan 9, 2025
2 parents 481e9b8 + 3d8dac2 commit 8d2e2a4
Show file tree
Hide file tree
Showing 3 changed files with 384 additions and 0 deletions.
48 changes: 48 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions tests/tools/schema_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
// SPDX-License-Identifier: MPL-2.0

// NOTE: https://github.com/ajv-validator/ajv-formats/issues/85
import Ajv from "https://esm.sh/[email protected]";
import addFormats from "https://esm.sh/[email protected]";

import { parse } from "npm:yaml";
import schema from "@local/tools/schema/metatype.json" with { type: "json" };
import * as path from "@std/path";
import { assert } from "@std/assert";
import { Meta } from "test-utils/mod.ts";

const files = [
"../metatype.yml",
"../../examples/metatype.yaml",
"../../examples/templates/deno/metatype.yaml",
"../../examples/templates/node/metatype.yaml",
"../../examples/templates/python/metatype.yaml",
"../metagen/typegraphs/sample/metatype.yml",
"../metagen/typegraphs/identities/metatype.yml",
];

Meta.test("Configuration schema", () => {
const ajv = new Ajv();

addFormats(ajv);

const validate = ajv.compile(schema);
const scriptDir = import.meta.dirname!;

for (const file of files) {
const relativePath = path.resolve(scriptDir, file);
const yaml = Deno.readTextFileSync(relativePath);
const parsed = parse(yaml);
const result = validate(parsed);

assert(result, `validation failed for '${file}'`);
}
});
Loading

0 comments on commit 8d2e2a4

Please sign in to comment.