-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into met-799-clear-out-cached-typegraphs-on-boot
- Loading branch information
Showing
3 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}'`); | ||
} | ||
}); |
Oops, something went wrong.