Skip to content

Commit 56d31f5

Browse files
YunchuWangCopilot
andauthored
Update packages/durabletask-js/test/orchestration_executor.spec.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 15bb7de commit 56d31f5

File tree

1 file changed

+23
-36
lines changed

1 file changed

+23
-36
lines changed

packages/durabletask-js/test/orchestration_executor.spec.ts

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,43 +1549,30 @@ describe("Orchestration Executor", () => {
15491549
expect(completeAction?.getResult()?.getValue()).toEqual(JSON.stringify(expectedResult));
15501550
});
15511551

1552-
it("should fail when orchestrator yields null as its first value", async () => {
1553-
// An orchestrator that yields null instead of a Task should fail with a clear error
1554-
const badOrchestrator: TOrchestrator = async function* (_ctx: OrchestrationContext): any {
1555-
yield null;
1556-
};
1557-
1558-
const registry = new Registry();
1559-
const name = registry.addOrchestrator(badOrchestrator);
1560-
const newEvents = [
1561-
newOrchestratorStartedEvent(),
1562-
newExecutionStartedEvent(name, TEST_INSTANCE_ID, undefined),
1563-
];
1564-
const executor = new OrchestrationExecutor(registry, testLogger);
1565-
const result = await executor.execute(TEST_INSTANCE_ID, [], newEvents);
1566-
const completeAction = getAndValidateSingleCompleteOrchestrationAction(result);
1567-
expect(completeAction?.getOrchestrationstatus()).toEqual(pb.OrchestrationStatus.ORCHESTRATION_STATUS_FAILED);
1568-
expect(completeAction?.getFailuredetails()?.getErrormessage()).toContain("non-Task");
1569-
});
1570-
1571-
it("should fail when orchestrator yields undefined as its first value", async () => {
1572-
// An orchestrator that yields undefined instead of a Task should fail with a clear error
1573-
const badOrchestrator: TOrchestrator = async function* (_ctx: OrchestrationContext): any {
1574-
yield undefined;
1575-
};
1552+
it.each([
1553+
{ description: "null", yieldedValue: null as any },
1554+
{ description: "undefined", yieldedValue: undefined as any },
1555+
])(
1556+
"should fail when orchestrator yields $description as its first value",
1557+
async ({ description, yieldedValue }) => {
1558+
// An orchestrator that yields a non-Task value as its first yield should fail with a clear error
1559+
const badOrchestrator: TOrchestrator = async function* (_ctx: OrchestrationContext): any {
1560+
yield yieldedValue;
1561+
};
15761562

1577-
const registry = new Registry();
1578-
const name = registry.addOrchestrator(badOrchestrator);
1579-
const newEvents = [
1580-
newOrchestratorStartedEvent(),
1581-
newExecutionStartedEvent(name, TEST_INSTANCE_ID, undefined),
1582-
];
1583-
const executor = new OrchestrationExecutor(registry, testLogger);
1584-
const result = await executor.execute(TEST_INSTANCE_ID, [], newEvents);
1585-
const completeAction = getAndValidateSingleCompleteOrchestrationAction(result);
1586-
expect(completeAction?.getOrchestrationstatus()).toEqual(pb.OrchestrationStatus.ORCHESTRATION_STATUS_FAILED);
1587-
expect(completeAction?.getFailuredetails()?.getErrormessage()).toContain("non-Task");
1588-
});
1563+
const registry = new Registry();
1564+
const name = registry.addOrchestrator(badOrchestrator);
1565+
const newEvents = [
1566+
newOrchestratorStartedEvent(),
1567+
newExecutionStartedEvent(name, TEST_INSTANCE_ID, undefined),
1568+
];
1569+
const executor = new OrchestrationExecutor(registry, testLogger);
1570+
const result = await executor.execute(TEST_INSTANCE_ID, [], newEvents);
1571+
const completeAction = getAndValidateSingleCompleteOrchestrationAction(result);
1572+
expect(completeAction?.getOrchestrationstatus()).toEqual(pb.OrchestrationStatus.ORCHESTRATION_STATUS_FAILED);
1573+
expect(completeAction?.getFailuredetails()?.getErrormessage()).toContain("non-Task");
1574+
}
1575+
);
15891576

15901577
it("should fail when orchestrator yields a plain object as its first value", async () => {
15911578
// An orchestrator that yields a non-Task object should fail with a clear error

0 commit comments

Comments
 (0)