@@ -130,6 +130,7 @@ describe("normalizeAndValidateConfig()", () => {
130130 upload_source_maps : undefined ,
131131 placement : undefined ,
132132 tail_consumers : undefined ,
133+ pipelines : [ ] ,
133134 } ) ;
134135 expect ( diagnostics . hasErrors ( ) ) . toBe ( false ) ;
135136 expect ( diagnostics . hasWarnings ( ) ) . toBe ( false ) ;
@@ -3181,6 +3182,114 @@ describe("normalizeAndValidateConfig()", () => {
31813182 } ) ;
31823183 } ) ;
31833184
3185+ describe ( "[pipelines]" , ( ) => {
3186+ it ( "should error if pipelines is an object" , ( ) => {
3187+ const { diagnostics } = normalizeAndValidateConfig (
3188+ // @ts -expect-error purposely using an invalid value
3189+ { pipelines : { } } ,
3190+ undefined ,
3191+ { env : undefined }
3192+ ) ;
3193+
3194+ expect ( diagnostics . hasWarnings ( ) ) . toBe ( false ) ;
3195+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
3196+ "Processing wrangler configuration:
3197+ - The field \\"pipelines\\" should be an array but got {}."
3198+ ` ) ;
3199+ } ) ;
3200+
3201+ it ( "should error if pipelines is a string" , ( ) => {
3202+ const { diagnostics } = normalizeAndValidateConfig (
3203+ // @ts -expect-error purposely using an invalid value
3204+ { pipelines : "BAD" } ,
3205+ undefined ,
3206+ { env : undefined }
3207+ ) ;
3208+
3209+ expect ( diagnostics . hasWarnings ( ) ) . toBe ( false ) ;
3210+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
3211+ "Processing wrangler configuration:
3212+ - The field \\"pipelines\\" should be an array but got \\"BAD\\"."
3213+ ` ) ;
3214+ } ) ;
3215+
3216+ it ( "should error if pipelines is a number" , ( ) => {
3217+ const { diagnostics } = normalizeAndValidateConfig (
3218+ // @ts -expect-error purposely using an invalid value
3219+ { pipelines : 999 } ,
3220+ undefined ,
3221+ { env : undefined }
3222+ ) ;
3223+
3224+ expect ( diagnostics . hasWarnings ( ) ) . toBe ( false ) ;
3225+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
3226+ "Processing wrangler configuration:
3227+ - The field \\"pipelines\\" should be an array but got 999."
3228+ ` ) ;
3229+ } ) ;
3230+
3231+ it ( "should error if pipelines is null" , ( ) => {
3232+ const { diagnostics } = normalizeAndValidateConfig (
3233+ // @ts -expect-error purposely using an invalid value
3234+ { pipelines : null } ,
3235+ undefined ,
3236+ { env : undefined }
3237+ ) ;
3238+
3239+ expect ( diagnostics . hasWarnings ( ) ) . toBe ( false ) ;
3240+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
3241+ "Processing wrangler configuration:
3242+ - The field \\"pipelines\\" should be an array but got null."
3243+ ` ) ;
3244+ } ) ;
3245+
3246+ it ( "should accept valid bindings" , ( ) => {
3247+ const { diagnostics } = normalizeAndValidateConfig (
3248+ {
3249+ pipelines : [
3250+ {
3251+ binding : "VALID" ,
3252+ pipeline : "343cd4f1d58c42fbb5bd082592fd7143" ,
3253+ } ,
3254+ ] ,
3255+ } as unknown as RawConfig ,
3256+ undefined ,
3257+ { env : undefined }
3258+ ) ;
3259+
3260+ expect ( diagnostics . hasErrors ( ) ) . toBe ( false ) ;
3261+ } ) ;
3262+
3263+ it ( "should error if pipelines.bindings are not valid" , ( ) => {
3264+ const { diagnostics } = normalizeAndValidateConfig (
3265+ {
3266+ pipelines : [
3267+ { } ,
3268+ {
3269+ binding : "VALID" ,
3270+ pipeline : "343cd4f1d58c42fbb5bd082592fd7143" ,
3271+ } ,
3272+ { binding : 2000 , project : 2111 } ,
3273+ ] ,
3274+ } as unknown as RawConfig ,
3275+ undefined ,
3276+ { env : undefined }
3277+ ) ;
3278+ expect ( diagnostics . renderWarnings ( ) ) . toMatchInlineSnapshot ( `
3279+ "Processing wrangler configuration:
3280+ - Unexpected fields found in pipelines[2] field: \\"project\\""
3281+ ` ) ;
3282+ expect ( diagnostics . hasWarnings ( ) ) . toBe ( true ) ;
3283+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
3284+ "Processing wrangler configuration:
3285+ - \\"pipelines[0]\\" bindings should have a string \\"binding\\" field but got {}.
3286+ - \\"pipelines[0]\\" bindings must have a \\"pipeline\\" field but got {}.
3287+ - \\"pipelines[2]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":2000,\\"project\\":2111}.
3288+ - \\"pipelines[2]\\" bindings must have a \\"pipeline\\" field but got {\\"binding\\":2000,\\"project\\":2111}."
3289+ ` ) ;
3290+ } ) ;
3291+ } ) ;
3292+
31843293 describe ( "[unsafe.bindings]" , ( ) => {
31853294 it ( "should error if unsafe is an array" , ( ) => {
31863295 const { diagnostics } = normalizeAndValidateConfig (
0 commit comments