diff --git a/meta-cli/tests/e2e.rs b/meta-cli/tests/e2e.rs deleted file mode 100644 index 0dce50bdf..000000000 --- a/meta-cli/tests/e2e.rs +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. -// SPDX-License-Identifier: MPL-2.0 - -mod e2e { - mod validator; -} diff --git a/meta-cli/tests/e2e/snapshots/e2e__e2e__validator__invalid_injections.snap b/meta-cli/tests/e2e/snapshots/e2e__e2e__validator__invalid_injections.snap deleted file mode 100644 index 493697109..000000000 --- a/meta-cli/tests/e2e/snapshots/e2e__e2e__validator__invalid_injections.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: meta-cli/tests/e2e/validator.rs -expression: stderr ---- - -[ERROR] at validator:/test/[in]/a: Expected number got '"1"' -[ERROR] at validator:/test/[in]/b: Expected a string, got '["h","e","l","l","o"]' -[ERROR] at validator:/test/[in]/c: Expected a minimum value of 2, got 0 -[ERROR] at validator:/test/[in]/d: Expected a maximun length of 4, got "hello" (len=5) -[ERROR] at validator:/test/[in]/e: Required field "a" not found in object '{}' -[ERROR] at validator:/test/[in]/f: Required field "a" not found in object '{"b":1}' -[ERROR] at validator:/test/[in]/g: Unexpected fields "b" in object "{\"a\":2,\"b\":1}" -[ERROR] at validator:/test/[out]/a: Expected number got '"1"' -[ERROR] at validator:/test/[out]/b: Expected a string, got '["h","e","l","l","o"]' -[ERROR] at validator:/test/[out]/c: Expected a minimum value of 2, got 0 -[ERROR] at validator:/test/[out]/d: Expected a maximun length of 4, got "hello" (len=5) -[ERROR] at validator:/test/[out]/e: Required field "a" not found in object '{}' -[ERROR] at validator:/test/[out]/f: Required field "a" not found in object '{"b":1}' -[ERROR] at validator:/test/[out]/g: Unexpected fields "b" in object "{\"a\":2,\"b\":1}" -[ERROR] at validator:/testEnums/[in]/a: Expected a minimum length of 4, got "hi" (len=2) -[ERROR] at validator:/testEnums/[in]/a: Expected a string, got '12' -[ERROR] at validator:/testEnums/[in]/b: Expected float got '"13"' -[ERROR] at validator:/testEnums/[out]/a: Expected a minimum length of 4, got "hi" (len=2) -[ERROR] at validator:/testEnums/[out]/a: Expected a string, got '12' -[ERROR] at validator:/testEnums/[out]/b: Expected float got '"13"' -Error: error while post processing typegraph validator from "tests/e2e/typegraphs/validator.py": Typegraph validator failed validation - diff --git a/meta-cli/tests/e2e/validator.rs b/meta-cli/tests/e2e/validator.rs deleted file mode 100644 index 93d9c8334..000000000 --- a/meta-cli/tests/e2e/validator.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. -// SPDX-License-Identifier: MPL-2.0 - -use std::process::Command; - -#[test] -fn test_invalid_injections() { - let status = Command::new("cargo") - .args(["build", "-p", "meta-cli", "--quiet"]) - .status() - .expect("failed to execute build for meta-cli"); - assert!(status.success(), "`cargo build -p meta-cli` failed"); - - let root = project_root::get_project_root().unwrap(); - let bin = root.join("target/debug/meta"); - let output = Command::new(bin) - .args(["serialize", "-f", "tests/e2e/typegraphs/validator.py"]) - .env("RUST_LOG", "error") - .output() - .expect("failed to execute process"); - let stderr = String::from_utf8(output.stderr).expect("failed to decode output"); - - assert!(!output.status.success()); - insta::assert_snapshot!("invalid_injections", stderr); -} diff --git a/meta-cli/tests/e2e/typegraphs/validator.py b/typegate/tests/e2e/typegraph/typegraphs/python/validator.py similarity index 100% rename from meta-cli/tests/e2e/typegraphs/validator.py rename to typegate/tests/e2e/typegraph/typegraphs/python/validator.py diff --git a/typegate/tests/e2e/typegraph/validator_test.ts b/typegate/tests/e2e/typegraph/validator_test.ts new file mode 100644 index 000000000..ea3e5d31d --- /dev/null +++ b/typegate/tests/e2e/typegraph/validator_test.ts @@ -0,0 +1,22 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +import { TestModule } from "test-utils/test_module.ts"; +import { Meta } from "test-utils/mod.ts"; +import { assert } from "std/assert/mod.ts"; + +const m = new TestModule(import.meta); + +Meta.test("typegraph validation", async (t) => { + await t.should( + "fail to serialize typegraph with invalid injection", + async () => { + try { + await m.cli({}, "serialize", "-f", "typegraphs/python/validator.py"); + assert(false, "should have thrown"); + } catch (e) { + await t.assertSnapshot(e.message); + } + }, + ); +});