@@ -305,10 +305,14 @@ describe('action', () => {
305
305
306
306
await main . run ( ) ;
307
307
expect ( runSpy ) . toHaveReturned ( ) ;
308
- expect ( process . exitCode ) . not . toBeDefined ( ) ;
308
+ expect ( process . exitCode ) . toEqual ( 1 ) ;
309
309
310
- expect ( core . setFailed ) . toHaveBeenLastCalledWith (
311
- 'JSON schema missing $schema key'
310
+ expect ( core . error ) . toHaveBeenLastCalledWith (
311
+ 'JSON schema missing $schema key' ,
312
+ {
313
+ title : 'JSON Schema Validation Error' ,
314
+ file : '/foo/bar'
315
+ }
312
316
) ;
313
317
} ) ;
314
318
@@ -359,6 +363,29 @@ describe('action', () => {
359
363
expect ( runSpy ) . toHaveReturned ( ) ;
360
364
expect ( process . exitCode ) . toEqual ( 1 ) ;
361
365
366
+ expect ( core . error ) . toHaveBeenCalledWith (
367
+ 'Error while validating file: /foo/bar/baz/config.yml'
368
+ ) ;
369
+ expect ( core . error ) . toHaveBeenLastCalledWith (
370
+ JSON . stringify (
371
+ {
372
+ instancePath : '' ,
373
+ schemaPath : '#/oneOf' ,
374
+ keyword : 'oneOf' ,
375
+ params : {
376
+ passingSchemas : [ 0 , 1 ]
377
+ } ,
378
+ message : 'must match exactly one schema in oneOf'
379
+ } ,
380
+ null ,
381
+ 4
382
+ ) ,
383
+ {
384
+ title : 'JSON Schema Validation Error' ,
385
+ file : '/foo/bar/baz/config.yml'
386
+ }
387
+ ) ;
388
+
362
389
expect ( core . setOutput ) . toHaveBeenCalledTimes ( 1 ) ;
363
390
expect ( core . setOutput ) . toHaveBeenLastCalledWith ( 'valid' , false ) ;
364
391
} ) ;
@@ -447,14 +474,36 @@ describe('action', () => {
447
474
} ) ;
448
475
449
476
it ( 'which are invalid' , async ( ) => {
450
- mockGetBooleanInput ( { 'fail-on-invalid' : false } ) ;
477
+ mockGetBooleanInput ( { 'fail-on-invalid' : true } ) ;
451
478
452
479
vi . mocked ( fs . readFile ) . mockResolvedValueOnce ( invalidSchemaContents ) ;
453
480
454
481
await main . run ( ) ;
455
482
expect ( runSpy ) . toHaveReturned ( ) ;
456
- expect ( process . exitCode ) . not . toBeDefined ( ) ;
483
+ expect ( process . exitCode ) . toEqual ( 1 ) ;
457
484
485
+ expect ( core . error ) . toHaveBeenCalledWith (
486
+ 'Error while validating file: /foo/bar/baz/config.yml'
487
+ ) ;
488
+ expect ( core . error ) . toHaveBeenLastCalledWith (
489
+ JSON . stringify (
490
+ {
491
+ instancePath : '/properties/foobar/minLength' ,
492
+ schemaPath : '#/definitions/nonNegativeInteger/type' ,
493
+ keyword : 'type' ,
494
+ params : {
495
+ type : 'integer'
496
+ } ,
497
+ message : 'must be integer'
498
+ } ,
499
+ null ,
500
+ 4
501
+ ) ,
502
+ {
503
+ title : 'JSON Schema Validation Error' ,
504
+ file : '/foo/bar/baz/config.yml'
505
+ }
506
+ ) ;
458
507
expect ( core . setOutput ) . toHaveBeenCalledTimes ( 1 ) ;
459
508
expect ( core . setOutput ) . toHaveBeenLastCalledWith ( 'valid' , false ) ;
460
509
} ) ;
@@ -482,10 +531,14 @@ describe('action', () => {
482
531
483
532
await main . run ( ) ;
484
533
expect ( runSpy ) . toHaveReturned ( ) ;
485
- expect ( process . exitCode ) . not . toBeDefined ( ) ;
486
-
487
- expect ( core . setFailed ) . toHaveBeenLastCalledWith (
488
- 'JSON schema missing $schema key'
534
+ expect ( process . exitCode ) . toEqual ( 1 ) ;
535
+
536
+ expect ( core . error ) . toHaveBeenLastCalledWith (
537
+ 'JSON schema missing $schema key' ,
538
+ {
539
+ title : 'JSON Schema Validation Error' ,
540
+ file : '/foo/bar/baz/config.yml'
541
+ }
489
542
) ;
490
543
} ) ;
491
544
} ) ;
0 commit comments