From fbb7287c6d9457cd090e8043e79dbfed1a0c0551 Mon Sep 17 00:00:00 2001 From: luckasRanarison Date: Tue, 3 Dec 2024 08:11:56 +0300 Subject: [PATCH] fix: metagen test --- src/typegraph/deno/deno.json | 8 ++++-- tests/metagen/metagen_test.ts | 52 +---------------------------------- 2 files changed, 6 insertions(+), 54 deletions(-) diff --git a/src/typegraph/deno/deno.json b/src/typegraph/deno/deno.json index b8882556f..b820ce11d 100644 --- a/src/typegraph/deno/deno.json +++ b/src/typegraph/deno/deno.json @@ -6,9 +6,7 @@ }, "lint": { "rules": { - "exclude": [ - "no-external-import" - ] + "exclude": ["no-external-import"] } }, "exports": { @@ -16,6 +14,10 @@ "./deps/mod.ts": "./src/deps/mod.ts", "./effects.ts": "./src/effects.ts", "./envs/cli.ts": "./src/envs/cli.ts", + "./gen/core.ts": "./src/gen/core.ts", + "./gen/runtimes.ts": "./src/gen/runtimes.ts", + "./gen/aws.ts": "./src/gen/aws.ts", + "./gen/utils.ts": "./src/gen/utils.ts", "./index.ts": "./src/index.ts", "./io.ts": "./src/io.ts", "./metagen.ts": "./src/metagen.ts", diff --git a/tests/metagen/metagen_test.ts b/tests/metagen/metagen_test.ts index b09181088..b6639e8b1 100644 --- a/tests/metagen/metagen_test.ts +++ b/tests/metagen/metagen_test.ts @@ -11,7 +11,7 @@ import { testDir } from "test-utils/dir.ts"; import $ from "@david/dax"; import { z as zod } from "zod"; import { workspaceDir } from "test-utils/dir.ts"; -import { FdkOutput } from "@typegraph/sdk/gen/typegraph_core.d.ts"; +import { FdkOutput } from "@typegraph/sdk/gen/utils.ts"; import { createBucket } from "test-utils/s3.ts"; import { S3Client } from "aws-sdk/client-s3"; @@ -213,56 +213,6 @@ metagen: // } //}); - const sdkResults = [] as Array; - - await t.should("Run metagen within typescript", async () => { - const { tg } = await import("./typegraphs/metagen.ts"); - const { Metagen } = await import("@typegraph/sdk/metagen"); - const metagen = new Metagen(workspace, genConfig); - const generated = metagen.dryRun(tg, targetName); - const sorted = generated.sort((a, b) => a.path.localeCompare(b.path)); - await t.assertSnapshot(sorted); - - sdkResults.push(JSON.stringify(sorted, null, 2)); - }); - - await t.should("Run metagen within python", async () => { - const typegraphPath = join(import.meta.dirname!, "./typegraphs/metagen.py"); - const command = new Deno.Command("python3", { - args: [typegraphPath], - env: { - workspace_path: workspace, - gen_config: JSON.stringify(genConfig), - target_name: targetName, - }, - stderr: "piped", - stdout: "piped", - }); - - const child = command.spawn(); - const output = await child.output(); - if (output.success) { - const stdout = new TextDecoder().decode(output.stdout); - const generated = JSON.parse(stdout) as Array; - const sorted = generated.sort((a, b) => a.path.localeCompare(b.path)); - - await t.assertSnapshot(sorted); - - sdkResults.push(JSON.stringify(sorted, null, 2)); - } else { - const err = new TextDecoder().decode(output.stderr); - throw new Error(`metagen python: ${err}`); - } - }); - - if (sdkResults.length > 0) { - await t.should("SDKs should produce same metagen output", () => { - const [fromTs, fromPy] = sdkResults; - assertEquals(fromTs, fromPy); - }); - } -}); - Meta.test("Metagen within sdk with custom template", async (t) => { const workspace = join(import.meta.dirname!, "typegraphs").slice( workspaceDir.length,