Skip to content

Commit

Permalink
update: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasRanarison committed Dec 9, 2024
1 parent f45cadc commit 559570d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
36 changes: 23 additions & 13 deletions tests/metagen/metagen_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,42 +656,52 @@ Meta.test(
assertEquals(res.code, 0);

const expectedSchemaU1 = zod.object({
upload: zod.boolean(),
upload: zod.literal(true),
});
const expectedSchemaU2 = zod.object({
uploadFirst: zod.literal(true),
uploadSecond: zod.literal(true),
});
const expectedSchemaUn = zod.object({
uploadMany: zod.boolean(),
uploadMany: zod.literal(true),
});

const expectedSchema = zod.tuple([
expectedSchemaU1,
// expectedSchemaU1,
expectedSchemaUn,
expectedSchemaU1,
expectedSchemaUn,
]);

const cases = [
{
name: "client_rs_upload",
skip: false,
command: $`cargo run`.cwd(join(scriptsPath, "rs_upload")),
expected: expectedSchema,
expected: zod.tuple([
expectedSchemaU1,
// expectedSchemaU1,
expectedSchemaUn,
expectedSchemaU1,
expectedSchemaUn,
]),
},
{
name: "client_py_upload",
skip: false,
command: $`bash -c "python main.py"`.cwd(
join(scriptsPath, "py_upload"),
),
expected: zod.tuple([expectedSchemaU1, expectedSchemaUn]),
expected: zod.tuple([
expectedSchemaU1,
expectedSchemaUn,
expectedSchemaU2,
]),
},
{
name: "client_ts_upload",
skip: false,
command: $`bash -c "deno run -A main.ts"`.cwd(
join(scriptsPath, "ts_upload"),
),
expected: zod.tuple([expectedSchemaU1, expectedSchemaUn]),
expected: zod.tuple([
expectedSchemaU1,
expectedSchemaUn,
expectedSchemaU2,
]),
},
];

Expand Down
11 changes: 10 additions & 1 deletion tests/metagen/typegraphs/sample/py_upload/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@
}
)

print(json.dumps([res1, res2]))
file = File(b"Hello", "reusable.txt")

res3 = gql.mutation(
{
"uploadFirst": api.upload({"file": file, "path": "python/first.txt"}),
"uploadSecond": api.upload({"file": file, "path": "python/second.txt"}),
}
)

print(json.dumps([res1, res2, res3]))
9 changes: 8 additions & 1 deletion tests/metagen/typegraphs/sample/ts_upload/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ const res2 = await gql.mutation({
}),
});

console.log(JSON.stringify([res1, res2]));
const file = new File(["Hello"], "reusable.txt", { type: "text/plain" });

const res3 = await gql.mutation({
uploadFirst: qg.upload({ file, path: "deno/first.txt" }),
uploadSecond: qg.upload({ file, path: "deno/second.txt" }),
});

console.log(JSON.stringify([res1, res2, res3]));

0 comments on commit 559570d

Please sign in to comment.