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 6416c1a
Showing 1 changed file with 1 addition and 51 deletions.
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/core.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 6416c1a

Please sign in to comment.