Skip to content

Commit 3bbd1d8

Browse files
committed
fix(test): update tg snapshots and tests using denoruntime with module import
1 parent b81934f commit 3bbd1d8

File tree

14 files changed

+907
-457
lines changed

14 files changed

+907
-457
lines changed

typegate/tests/e2e/typegraph/__snapshots__/typegraph_test.ts.snap

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,13 @@ snapshot[`typegraphs creation 3`] = `
687687
"idempotent": true
688688
},
689689
"data": {
690-
"code": "file:scripts/three.ts;base64:H4sIAAAAAAAA/+1Y727bNhD3Zz0FoX6ROlX1n8QZvKnY1nZdgRYL2mwYEAQCLdG2UEnUSGqxZ/hN9jZ7sR1J/becpEASDK0PSEzyjse7I3n86QKaZDFZu9lm8GA0BJpOp73jQJPJ6UnZliTb05Ozs8Fw8AiUc4EZQoOvlJ6glzTbsGi5Eug9EVhsMoJ+/fcfB8VRQFJOQpSnIWFIrAh6T/+O4hij83wOXPROS6DfCeMRTdHYHbrGE/Tx/NUfzwres7chSUW0iAiboffn756BjGEsGE2QXGnJcLZCUZJRJpBw6rGOiKv/Z5jhhJfyP+Zi5YD5jDvoAxakf87eMm/69GcUHNqUIueq15VhOXiSEO6CS7QUfQXtD5phGMYPlbRlIKAAjPOkhborCccxvfYDRlRgcMy9n+EfcToCK4Ih6ty7vOpyEiJWNASO+eb1hbnHprCXUQrcp00eWWeUk16tCV77eEl8TgJvNB5qhq1/GITVk7Gt7b+O0hCWkdLTodMdjqMkEqDm25rzZ07YpmA0hmMa4Ngn64Bw7p3W4wFNBVkLP6oOjmfmnDCzMsw2QrJAgnDhBzp7+TLs3FrO9ObaMyWqtslr7pBlK0aWz2Fcb7KbqbMMHMXiNCEX8gp4SLhcsDwQtevbqiXJpCkxZyAWR1xYwo3A7iVhlu2gBDZg4qAUJ8QzL66paTvtqQLG5FSaCbg4OLaWLiMLy/xYLG/ajRm7uqk1VlJFSIzirKlY3NV67INAlC6VHbppdc3E/iKmWCgR1bKkZyN3CC7msYhgPZ8u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6YgoAVCV0DCPod/FWzeZpE9Dd9ljHeNIRzrS/dB/B6n8KQAeAAA="
690+
"denoArtifact": {
691+
"path": "scripts/three.ts",
692+
"hash": "564fe4792102c50aac9801faeb3c6402c49b1f7c7cbb22dc6d54886e45cfa3b2",
693+
"size": 307
694+
},
695+
"deps": [],
696+
"depsMeta": []
691697
}
692698
},
693699
{
@@ -744,7 +750,13 @@ snapshot[`typegraphs creation 3`] = `
744750
"rate": null,
745751
"version": "0.0.3",
746752
"randomSeed": null,
747-
"artifacts": {}
753+
"artifacts": {
754+
"scripts/three.ts": {
755+
"path": "scripts/three.ts",
756+
"hash": "564fe4792102c50aac9801faeb3c6402c49b1f7c7cbb22dc6d54886e45cfa3b2",
757+
"size": 307
758+
}
759+
}
748760
}
749761
}
750762
]\`
@@ -1437,7 +1449,13 @@ snapshot[`typegraphs creation 6`] = `
14371449
"idempotent": true
14381450
},
14391451
"data": {
1440-
"code": "file:scripts/three.ts;base64:H4sIAAAAAAAA/+1Y/W7bNhDP336Kg/6p3CnyV+wO6lqsa4u1QIcGbQYMCAyDlihHiyRqIjXbMPwme5u92I4fkmjnsxiSYa2JxKKOx+Pd8Xj86UKWFSld+YIfPVjrY5tMJtfSsY1Go0ndl032JyfPxkf9o0doFRekBDj6RluvB69ZsS6TxYWAX6ggYl1Q+Pj3Xx6kSUhzTiOo8oiWIC4ovE0JF0kIH/QQDP2+30ERn0/f/HZsiMfvI5qLJE5oGdQTjpGx00mygpUCNhCvPDhlKH/tgcA/XHJRkuICthCXLAPnx4bU49Gl87yd+obm7FOF8jN6A3ev1MO8h3ow/3duT39ViZtW6RWkJBnXEzrNkNsB2OA/QE4yGoAjKBfHoT42x5KNO54a5zQsqeABnDu6O3A8MN1h2x05U81fEoHytGyAZZJHbPmZhgFM+t4O8UOSJSKAwfD7mv5HRcu1ITfElIUkfbsKKUcdxjU1ZLmgK2FvilNxWhqlt/oRspK3upA0ZcvXJVVzSIojMf5Szx5+RwlGhbR2ukPHGLpgkfLC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PD+X+E9g3hv47GUUSVS5rv9YbOBzt1FHXgd+sXukgiyyL641vPm+/Ia7g8Wb4K4GSkefeBoykc3gAW74EGb4eTKtViBaLlqSkGLGo2WQi8Wj1KIttuA5gQWWI6NSWrU3xxNPaxyhO/yrJiXZcwaiLjPReQlQmGISN12pes1qsl7+FcVZJrsSLHutK8LSrtlBkGw7rquYPjatcYRVSZrhWo9FGGXJUqx5Rk3HdplNx25dNt99qVlNRC9x18WcsKmtZNVVibEqC65owWOuxrEIz2Xek1flLTUGbGoiqVhH149/UC2UM7tEM7tEP7ovYPKoqBEgAgAAA="
1452+
"denoArtifact": {
1453+
"path": "scripts/three.ts",
1454+
"hash": "564fe4792102c50aac9801faeb3c6402c49b1f7c7cbb22dc6d54886e45cfa3b2",
1455+
"size": 307
1456+
},
1457+
"deps": [],
1458+
"depsMeta": []
14411459
}
14421460
},
14431461
{
@@ -1494,7 +1512,13 @@ snapshot[`typegraphs creation 6`] = `
14941512
"rate": null,
14951513
"version": "0.0.3",
14961514
"randomSeed": null,
1497-
"artifacts": {}
1515+
"artifacts": {
1516+
"scripts/three.ts": {
1517+
"path": "scripts/three.ts",
1518+
"hash": "564fe4792102c50aac9801faeb3c6402c49b1f7c7cbb22dc6d54886e45cfa3b2",
1519+
"size": 307
1520+
}
1521+
}
14981522
}
14991523
}
15001524
]\`

typegate/tests/internal/internal.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
from typegraph import Graph, Policy, t, typegraph
1+
import os
2+
import sys
3+
4+
from typegraph.gen.exports.core import (
5+
ArtifactResolutionConfig,
6+
MigrationAction,
7+
MigrationConfig,
8+
)
9+
from typegraph.graph.shared_types import BasicAuth
10+
from typegraph.graph.tg_deploy import TypegraphDeployParams, tg_deploy
11+
from typegraph.graph.typegraph import Graph
12+
from typegraph.policy import Policy
213
from typegraph.runtimes.deno import DenoRuntime
314

15+
from typegraph import t, typegraph
16+
417

518
@typegraph()
619
def test_internal(g: Graph):
@@ -20,3 +33,32 @@ def test_internal(g: Graph):
2033
inp, out, module="ts/logic.ts", name="remoteSum"
2134
).with_policy(public),
2235
)
36+
37+
38+
cwd = sys.argv[1]
39+
PORT = sys.argv[2]
40+
gate = f"http://localhost:{PORT}"
41+
auth = BasicAuth("admin", "password")
42+
43+
tg = test_internal()
44+
deploy_result = tg_deploy(
45+
tg,
46+
TypegraphDeployParams(
47+
base_url=gate,
48+
auth=auth,
49+
typegraph_path=os.path.join(cwd, "internal.py"),
50+
artifacts_config=ArtifactResolutionConfig(
51+
dir=cwd,
52+
prefix=None,
53+
disable_artifact_resolution=None,
54+
codegen=None,
55+
prisma_migration=MigrationConfig(
56+
migration_dir="prisma-migrations",
57+
global_action=MigrationAction(reset=False, create=True),
58+
runtime_actions=None,
59+
),
60+
),
61+
),
62+
)
63+
64+
print(deploy_result.serialized)

typegate/tests/internal/internal_test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
// Copyright Metatype OÜ, licensed under the Elastic License 2.0.
22
// SPDX-License-Identifier: Elastic-2.0
33

4+
import { testDir } from "test-utils/dir.ts";
45
import { gql, Meta } from "../utils/mod.ts";
6+
import * as path from "std/path/mod.ts";
7+
8+
const cwd = path.join(testDir, "internal");
59

610
Meta.test({
711
name: "Internal test",
812
port: true,
13+
systemTypegraphs: true,
914
}, async (t) => {
10-
const e = await t.engine("internal/internal.py");
15+
const e = await t.engineFromTgDeployPython("internal/internal.py", cwd);
1116

1217
await t.should("work on the default worker", async () => {
1318
await gql`

typegate/tests/schema_validation/circular.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
from typegraph import typegraph, Policy, t, Graph
1+
import os
2+
import sys
3+
4+
from typegraph.gen.exports.core import (
5+
ArtifactResolutionConfig,
6+
MigrationAction,
7+
MigrationConfig,
8+
)
9+
from typegraph.graph.shared_types import BasicAuth
10+
from typegraph.graph.tg_deploy import TypegraphDeployParams, tg_deploy
11+
from typegraph.graph.typegraph import Graph
12+
from typegraph.policy import Policy
213
from typegraph.runtimes.deno import DenoRuntime
314

15+
from typegraph import t, typegraph
16+
417

518
@typegraph()
619
def circular(g: Graph):
@@ -59,3 +72,32 @@ def circular(g: Graph):
5972
).with_policy(public)
6073

6174
g.expose(registerUser=register_user)
75+
76+
77+
cwd = sys.argv[1]
78+
PORT = sys.argv[2]
79+
gate = f"http://localhost:{PORT}"
80+
auth = BasicAuth("admin", "password")
81+
82+
tg = circular()
83+
deploy_result = tg_deploy(
84+
tg,
85+
TypegraphDeployParams(
86+
base_url=gate,
87+
auth=auth,
88+
typegraph_path=os.path.join(cwd, "circular.py"),
89+
artifacts_config=ArtifactResolutionConfig(
90+
dir=cwd,
91+
prefix=None,
92+
disable_artifact_resolution=None,
93+
codegen=None,
94+
prisma_migration=MigrationConfig(
95+
migration_dir="prisma-migrations",
96+
global_action=MigrationAction(reset=False, create=True),
97+
runtime_actions=None,
98+
),
99+
),
100+
),
101+
)
102+
103+
print(deploy_result.serialized)

typegate/tests/schema_validation/circular_test.ts

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
// Copyright Metatype OÜ, licensed under the Elastic License 2.0.
22
// SPDX-License-Identifier: Elastic-2.0
33

4+
import { testDir } from "test-utils/dir.ts";
45
import { gql, Meta } from "../utils/mod.ts";
6+
import * as path from "std/path/mod.ts";
57

6-
Meta.test("circular test", async (t) => {
7-
const tgPath = "schema_validation/circular.py";
8-
const e = await t.engine(tgPath);
8+
const cwd = path.join(testDir, "schema_validation");
99

10-
await t.should("validate self-refering type", async () => {
11-
await gql`
10+
Meta.test(
11+
{
12+
name: "circular test",
13+
port: true,
14+
systemTypegraphs: true,
15+
},
16+
async (t) => {
17+
const tgPath = "schema_validation/circular.py";
18+
const e = await t.engineFromTgDeployPython(tgPath, cwd);
19+
20+
await t.should("validate self-refering type", async () => {
21+
await gql`
1222
query {
1323
registerUser(
1424
user: {
@@ -42,19 +52,19 @@ Meta.test("circular test", async (t) => {
4252
}
4353
}
4454
`
45-
.expectData({
46-
registerUser: {
47-
message: "John registered",
48-
user: {
49-
name: "John",
55+
.expectData({
56+
registerUser: {
57+
message: "John registered",
58+
user: {
59+
name: "John",
60+
},
5061
},
51-
},
52-
})
53-
.on(e);
54-
});
62+
})
63+
.on(e);
64+
});
5565

56-
await t.should("not validate missing field", async () => {
57-
await gql`
66+
await t.should("not validate missing field", async () => {
67+
await gql`
5868
query {
5969
registerUser(
6070
user: {
@@ -72,7 +82,8 @@ Meta.test("circular test", async (t) => {
7282
}
7383
}
7484
`
75-
.expectErrorContains("mandatory argument 'user.friends.parents'")
76-
.on(e);
77-
});
78-
});
85+
.expectErrorContains("mandatory argument 'user.friends.parents'")
86+
.on(e);
87+
});
88+
},
89+
);

typegate/tests/type_nodes/either_node.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
from typegraph import Policy, t, typegraph, Graph
1+
import os
2+
import sys
3+
4+
from typegraph.gen.exports.core import (
5+
ArtifactResolutionConfig,
6+
MigrationAction,
7+
MigrationConfig,
8+
)
9+
from typegraph.graph.shared_types import BasicAuth
10+
from typegraph.graph.tg_deploy import TypegraphDeployParams, tg_deploy
11+
from typegraph.graph.typegraph import Graph
12+
from typegraph.policy import Policy
213
from typegraph.runtimes.deno import DenoRuntime
314

15+
from typegraph import t, typegraph
16+
417

518
@typegraph()
619
def either(g: Graph):
@@ -60,3 +73,32 @@ def either(g: Graph):
6073
).with_policy(public)
6174

6275
g.expose(regist_user=regist_user)
76+
77+
78+
cwd = sys.argv[1]
79+
PORT = sys.argv[2]
80+
gate = f"http://localhost:{PORT}"
81+
auth = BasicAuth("admin", "password")
82+
83+
tg = either()
84+
deploy_result = tg_deploy(
85+
tg,
86+
TypegraphDeployParams(
87+
base_url=gate,
88+
auth=auth,
89+
typegraph_path=os.path.join(cwd, "either_node.py"),
90+
artifacts_config=ArtifactResolutionConfig(
91+
dir=cwd,
92+
prefix=None,
93+
disable_artifact_resolution=None,
94+
codegen=None,
95+
prisma_migration=MigrationConfig(
96+
migration_dir="prisma-migrations",
97+
global_action=MigrationAction(reset=False, create=True),
98+
runtime_actions=None,
99+
),
100+
),
101+
),
102+
)
103+
104+
print(deploy_result.serialized)

0 commit comments

Comments
 (0)