Skip to content

Commit 354ee3c

Browse files
authored
Add TypeScript SDK coordinator schema-mapping tests (#69297)
1 parent f0953fb commit 354ee3c

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

ts-sdk/tests/coordinator/client.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,29 @@ describe("client is bound to TaskContext", () => {
125125
});
126126
});
127127

128+
it("defaults getXCom locator fields from ctx with snake_case wire names", async () => {
129+
const sent: Record<string, unknown>[] = [];
130+
const recordingComm = {
131+
request: async (b: Record<string, unknown>) => {
132+
sent.push(b);
133+
return { body: { type: "XComResult", key: b.key, value: null } };
134+
},
135+
} as unknown as CommChannel;
136+
const c = createCoordinatorClient(recordingComm, FAKE_CTX);
137+
138+
await c.getXCom({ key: "k" });
139+
140+
expect(sent[0]).toEqual({
141+
type: "GetXCom",
142+
key: "k",
143+
dag_id: "d",
144+
task_id: "t",
145+
run_id: "r",
146+
map_index: null,
147+
include_prior_dates: false,
148+
});
149+
});
150+
128151
it("maps camelCase public XCom options to snake_case supervisor fields", async () => {
129152
const sent: Record<string, unknown>[] = [];
130153
const recordingComm = {
@@ -197,6 +220,23 @@ describe("getConnection", () => {
197220
});
198221
});
199222

223+
it("coerces absent optional wire fields to null public fields", async () => {
224+
const c = client([
225+
{ body: { type: "ConnectionResult", conn_id: "bare", conn_type: "generic" } },
226+
]);
227+
228+
await expect(c.getConnection("bare")).resolves.toEqual({
229+
id: "bare",
230+
type: "generic",
231+
host: null,
232+
schema: null,
233+
login: null,
234+
password: null,
235+
port: null,
236+
extra: null,
237+
});
238+
});
239+
200240
it("returns null for missing connections", async () => {
201241
const c = client([{ body: { type: "ErrorResponse", error: "CONNECTION_NOT_FOUND" } }]);
202242
expect(await c.getConnection("missing")).toBeNull();

ts-sdk/tests/coordinator/integration.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ describe("coordinator runtime integration", () => {
248248
taskId: "say_hello",
249249
dagId: "test_dag",
250250
runId: "r1",
251+
tryNumber: 1,
252+
mapIndex: -1,
251253
});
252254
expect(result.logRecords.some((r) => r["event"] === "[ts-sdk.runtime] Task succeeded")).toBe(
253255
true,

0 commit comments

Comments
 (0)