Skip to content

Commit

Permalink
fix: metagen test
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasRanarison committed Dec 3, 2024
1 parent 3ac927e commit fbb7287
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 54 deletions.
8 changes: 5 additions & 3 deletions src/typegraph/deno/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
},
"lint": {
"rules": {
"exclude": [
"no-external-import"
]
"exclude": ["no-external-import"]
}
},
"exports": {
"./deps/_import.ts": "./src/deps/_import.ts",
"./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",
Expand Down
52 changes: 1 addition & 51 deletions tests/metagen/metagen_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -213,56 +213,6 @@ metagen:
// }
//});

const sdkResults = [] as Array<string>;

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<FdkOutput>;
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,
Expand Down

0 comments on commit fbb7287

Please sign in to comment.