Skip to content

Commit b656d97

Browse files
committed
feat: finalize test suite to run and test tg deploy on both python and ts SDK
1 parent bd29db4 commit b656d97

File tree

2 files changed

+46
-25
lines changed

2 files changed

+46
-25
lines changed

typegate/tests/runtimes/wasmedge/wasmedge_test.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ import * as path from "std/path/mod.ts";
88

99
const cwd = path.join(testDir, "runtimes/wasmedge");
1010

11-
// Meta.test(
12-
// {
13-
// name: "WasmEdge runtime: Python SDK",
14-
// port: true,
15-
// systemTypegraphs: true,
16-
// },
17-
// async (t) => {
18-
// await t.should("works on the Python SDK", async () => {
19-
// const engine = await t.engineFromTgDeploy(
20-
// "runtimes/wasmedge/wasmedge.py",
21-
// cwdDir,
22-
// );
11+
Meta.test(
12+
{
13+
name: "WasmEdge runtime: Python SDK",
14+
port: true,
15+
systemTypegraphs: true,
16+
},
17+
async (t) => {
18+
await t.should("works on the Python SDK", async () => {
19+
const engine = await t.engineFromTgDeploy(
20+
"runtimes/wasmedge/wasmedge.py",
21+
cwd,
22+
);
2323

24-
// await gql`
25-
// query {
26-
// test(a: 1, b: 2)
27-
// }
28-
// `
29-
// .expectData({
30-
// test: 3,
31-
// })
32-
// .on(engine);
33-
// });
34-
// },
35-
// );
24+
await gql`
25+
query {
26+
test(a: 1, b: 2)
27+
}
28+
`
29+
.expectData({
30+
test: 3,
31+
})
32+
.on(engine);
33+
});
34+
},
35+
);
3636

3737
Meta.test({
3838
name: "WasmEdge Runtime typescript sdk",

typegate/tests/utils/test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,12 @@ export class MetaTest {
286286
throw new Error("No typegraph");
287287
}
288288

289-
return stdout;
289+
const tg_json = extractJsonFromStdout(stdout);
290+
if (!tg_json) {
291+
throw new Error("No typegraph");
292+
}
293+
294+
return tg_json;
290295
}
291296

292297
async unregister(engine: QueryEngine) {
@@ -364,6 +369,22 @@ export class MetaTest {
364369
}
365370
}
366371

372+
function extractJsonFromStdout(stdout: string): string | null {
373+
let jsonStart = null;
374+
let inJson = false;
375+
376+
for (const line of stdout.split("\n")) {
377+
if (inJson) {
378+
jsonStart += "\n" + line;
379+
} else if (line.startsWith("{")) {
380+
jsonStart = line;
381+
inJson = true;
382+
}
383+
}
384+
385+
return jsonStart;
386+
}
387+
367388
interface TempGitRepo {
368389
content: Record<string, string>;
369390
}

0 commit comments

Comments
 (0)