Pebble32 commented on code in PR #77392:
URL: https://github.com/apache/airflow/pull/77392#discussion_r4695338221


##########
ts-sdk/tests/sdk/dag.test.ts:
##########
@@ -417,6 +422,51 @@ describe("Dag", () => {
     expect(dag.taskIds).toEqual([]);
   });
 
+  it.each(["all_sucess", "ALL_SUCCESS", ""])(
+    "rejects the unknown trigger rule %j",
+    (triggerRule) => {
+      const dag = new Dag("example_dag");
+      expect(() => dag.task("transform", async () => undefined, { triggerRule 
})).toThrowError(
+        `triggerRule in the spec for Dag "example_dag" task "transform" is 
${JSON.stringify(triggerRule)}; ` +
+          "use one of all_success,",
+      );
+      expect(dag.taskIds).toEqual([]);
+    },
+  );
+
+  it.each(["upwards", "Upstream", "", 
"my_plugin.strategies.DecreasingPriorityStrategy"])(
+    "rejects the unknown weight rule %j",
+    (weightRule) => {
+      const dag = new Dag("example_dag");
+      expect(() => dag.task("transform", async () => undefined, { weightRule 
})).toThrowError(
+        `weightRule in the spec for Dag "example_dag" task "transform" is 
${JSON.stringify(weightRule)}; ` +
+          "use one of downstream, upstream, absolute",
+      );
+      expect(dag.taskIds).toEqual([]);
+    },
+  );
+
+  it("accepts every trigger rule and weight rule", () => {
+    const dag = new Dag("example_dag");
+    for (const triggerRule of TRIGGER_RULES)
+      dag.task(`t_${triggerRule}`, async () => undefined, { triggerRule });
+    for (const weightRule of WEIGHT_RULES)
+      dag.task(`w_${weightRule}`, async () => undefined, { weightRule });
+    expect(dag.taskIds).toHaveLength(TRIGGER_RULES.size + WEIGHT_RULES.size);
+  });
+
+  it.each([
+    ["trigger_rule.py", TRIGGER_RULES],
+    ["weight_rule.py", WEIGHT_RULES],
+  ])("matches the values of Airflow's %s", (file, rules) => {
+    const source = readFileSync(
+      join(dirname(fileURLToPath(import.meta.url)), 
"../../../airflow-core/src/airflow/task", file),
+      "utf8",
+    );

Review Comment:
   I will check it out thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to