Skip to content

Commit 52bf274

Browse files
jason810496claude
authored andcommitted
Pin the Code view to the entry module in Node bundle tests
The tests used a Dag's own file as the entrypoint, so a resolver that returned the first dag_source_paths entry would still pass. Use a separate main.ts entrypoint instead. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 83e1a0e commit 52bf274

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎task-sdk/tests/task_sdk/coordinators/node/test_bundle_reader.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,16 @@ def test_reads_one_source_region_per_dag(self, tmp_path):
357357
sources=[
358358
("sales.ts", b"export const sales = 1;\n"),
359359
("inventory.ts", b"export const inv = 2;\n"),
360+
("main.ts", b'import "./sales";\n'),
360361
],
361362
dag_source_paths={"sales": "sales.ts", "inventory": "inventory.ts"},
362-
entrypoint_path="sales.ts",
363+
entrypoint_path="main.ts",
363364
)
364365

365366
assert read_bundle(bundle).dag_ids == frozenset({"sales", "inventory"})
366367
assert read_bundle_source(bundle, "sales") == "export const sales = 1;\n"
367368
assert read_bundle_source(bundle, "inventory") == "export const inv = 2;\n"
368-
assert read_bundle_entrypoint_source(bundle) == "export const sales = 1;\n"
369+
assert read_bundle_entrypoint_source(bundle) == 'import "./sales";\n'
369370

370371
def test_reads_no_entrypoint_source_when_none_is_declared(self, tmp_path):
371372
bundle = write_bundle(tmp_path, "sales", entrypoint_path=None)

‎task-sdk/tests/task_sdk/coordinators/node/test_dag_importer.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,23 @@ def raise_permission_error(self, *args, **kwargs):
9494

9595
class TestGetSourceCode:
9696
def test_returns_the_entrypoint_source_for_every_dag(self, importer, tmp_path):
97-
sales = '/* the */ export const sales = new Dag({ dagId: "sales" });\n'
97+
sales = 'export const sales = new Dag({ dagId: "sales" });\n'
9898
inventory = 'export const inventory = new Dag({ dagId: "inventory" });\n'
99+
main = '/* the */ import "./sales";\nimport "./inventory";\n'
99100
path = write_bundle(
100101
tmp_path,
101102
"sales",
102103
"inventory",
103-
sources=[("sales.ts", sales.encode()), ("inventory.ts", inventory.encode())],
104+
sources=[
105+
("sales.ts", sales.encode()),
106+
("inventory.ts", inventory.encode()),
107+
("main.ts", main.encode()),
108+
],
104109
dag_source_paths={"sales": "sales.ts", "inventory": "inventory.ts"},
105-
entrypoint_path="sales.ts",
110+
entrypoint_path="main.ts",
106111
)
107112

108-
assert importer.get_source_code(FilesystemDagDefinition(path)) == DagSourceCode(sales, "typescript")
113+
assert importer.get_source_code(FilesystemDagDefinition(path)) == DagSourceCode(main, "typescript")
109114

110115
def test_returns_a_notice_without_an_entrypoint_source(self, importer, tmp_path):
111116
path = write_bundle(tmp_path, "sales", entrypoint_path=None)

0 commit comments

Comments
 (0)