@@ -73,14 +73,51 @@ describe("registry", () => {
7373 const registry = new TaskRegistry ( ) ;
7474 expect ( ( ) =>
7575 registry . register ( { dagId : "" , taskId : "my_task" } , async ( ) => undefined ) ,
76- ) . toThrowError ( / d a g I d m u s t b e a n o n - e m p t y s t r i n g / ) ;
76+ ) . toThrowError ( / d a g I d m u s t b e m a d e o f a l p h a n u m e r i c / ) ;
7777 } ) ;
7878
7979 it ( "rejects an empty taskId" , ( ) => {
8080 const registry = new TaskRegistry ( ) ;
8181 expect ( ( ) =>
8282 registry . register ( { dagId : "example_dag" , taskId : "" } , async ( ) => undefined ) ,
83- ) . toThrowError ( / t a s k I d m u s t b e a n o n - e m p t y s t r i n g / ) ;
83+ ) . toThrowError ( / t a s k I d m u s t b e m a d e o f a l p h a n u m e r i c / ) ;
84+ } ) ;
85+
86+ it . each ( [ " " , "\t" , "my dag" , "a/b" , "task@1" ] ) (
87+ "rejects a dagId with characters no Python dag_id allows: %j" ,
88+ ( dagId ) => {
89+ const registry = new TaskRegistry ( ) ;
90+ expect ( ( ) =>
91+ registry . register ( { dagId, taskId : "my_task" } , async ( ) => undefined ) ,
92+ ) . toThrowError ( / d a g I d m u s t b e m a d e o f a l p h a n u m e r i c / ) ;
93+ } ,
94+ ) ;
95+
96+ it . each ( [ " " , "\t" , "my task" , "a/b" , "task@1" ] ) (
97+ "rejects a taskId with characters no Python task_id allows: %j" ,
98+ ( taskId ) => {
99+ const registry = new TaskRegistry ( ) ;
100+ expect ( ( ) =>
101+ registry . register ( { dagId : "example_dag" , taskId } , async ( ) => undefined ) ,
102+ ) . toThrowError ( / t a s k I d m u s t b e m a d e o f a l p h a n u m e r i c / ) ;
103+ } ,
104+ ) ;
105+
106+ it . each ( [
107+ [ "dagId" , { dagId : "d" . repeat ( 251 ) , taskId : "my_task" } ] ,
108+ [ "taskId" , { dagId : "example_dag" , taskId : "t" . repeat ( 251 ) } ] ,
109+ ] ) ( "rejects a %s longer than 250 characters" , ( name , registration ) => {
110+ const registry = new TaskRegistry ( ) ;
111+ expect ( ( ) => registry . register ( registration , async ( ) => undefined ) ) . toThrowError (
112+ new RegExp ( `${ name } must be less than 250 characters, not 251` ) ,
113+ ) ;
114+ } ) ;
115+
116+ it ( "accepts a Unicode dagId that Python's word-character rule allows" , ( ) => {
117+ const registry = new TaskRegistry ( ) ;
118+ const handler = async ( ) => undefined ;
119+ registry . register ( { dagId : "café_dag" , taskId : "任務" } , handler ) ;
120+ expect ( registry . get ( "café_dag" , "任務" ) ) . toBe ( handler ) ;
84121 } ) ;
85122
86123 it ( "rejects non-function handlers" , ( ) => {
0 commit comments