Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions ts-sdk/tests/coordinator/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,29 @@ describe("client is bound to TaskContext", () => {
});
});

it("defaults getXCom locator fields from ctx with snake_case wire names", async () => {
const sent: Record<string, unknown>[] = [];
const recordingComm = {
request: async (b: Record<string, unknown>) => {
sent.push(b);
return { body: { type: "XComResult", key: b.key, value: null } };
},
} as unknown as CommChannel;
const c = createCoordinatorClient(recordingComm, FAKE_CTX);

await c.getXCom({ key: "k" });

expect(sent[0]).toEqual({
type: "GetXCom",
key: "k",
dag_id: "d",
task_id: "t",
run_id: "r",
map_index: null,
include_prior_dates: false,
});
});

it("maps camelCase public XCom options to snake_case supervisor fields", async () => {
const sent: Record<string, unknown>[] = [];
const recordingComm = {
Expand Down Expand Up @@ -197,6 +220,23 @@ describe("getConnection", () => {
});
});

it("coerces absent optional wire fields to null public fields", async () => {
const c = client([
{ body: { type: "ConnectionResult", conn_id: "bare", conn_type: "generic" } },
]);

await expect(c.getConnection("bare")).resolves.toEqual({
id: "bare",
type: "generic",
host: null,
schema: null,
login: null,
password: null,
port: null,
extra: null,
});
});

it("returns null for missing connections", async () => {
const c = client([{ body: { type: "ErrorResponse", error: "CONNECTION_NOT_FOUND" } }]);
expect(await c.getConnection("missing")).toBeNull();
Expand Down
2 changes: 2 additions & 0 deletions ts-sdk/tests/coordinator/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ describe("coordinator runtime integration", () => {
taskId: "say_hello",
dagId: "test_dag",
runId: "r1",
tryNumber: 1,
mapIndex: -1,
});
expect(result.logRecords.some((r) => r["event"] === "[ts-sdk.runtime] Task succeeded")).toBe(
true,
Expand Down