jason810496 commented on code in PR #77392:
URL: https://github.com/apache/airflow/pull/77392#discussion_r4695274588
##########
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:
The TS source release will hold only `ts-sdk/`, so this read fails with
ENOENT there. Could we skip it outside the monorepo?
Checking the `airflow-core` root, not the rule files, keeps a moved file a
loud failure in CI.
```suggestion
const coreDir = join(dirname(fileURLToPath(import.meta.url)),
"../../../airflow-core");
// Skipped outside the monorepo, such as in an extracted source release.
it.skipIf(!existsSync(coreDir)).each([
["trigger_rule.py", TRIGGER_RULES],
["weight_rule.py", WEIGHT_RULES],
])("matches the values of Airflow's %s", (file, rules) => {
const source = readFileSync(join(coreDir, "src/airflow/task", file),
"utf8");
```
##########
ts-sdk/tests/sdk/dag.test.ts:
##########
@@ -17,6 +17,9 @@
* under the License.
*/
+import { readFileSync } from "node:fs";
Review Comment:
```suggestion
import { existsSync, readFileSync } from "node:fs";
```
--
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]