@@ -552,7 +552,7 @@ describe('setup-node', () => {
552
552
expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempt to resolve the latest version from manifest...' ) ;
553
553
expect ( warningSpy ) . toHaveBeenCalledWith ( 'LTS version is provided. For LTS versions `check-latest` will be automatically set to true' )
554
554
expect ( dbgSpy ) . toHaveBeenCalledWith ( `LTS alias 'erbium' for Node version 'lts/erbium'` )
555
- expect ( dbgSpy ) . toHaveBeenCalledWith ( `Found LTS release 'erbium ' for Node version 'lts/erbium'` )
555
+ expect ( dbgSpy ) . toHaveBeenCalledWith ( `Found LTS release '12.16.2 ' for Node version 'lts/erbium'` )
556
556
expect ( logSpy ) . toHaveBeenCalledWith ( "Resolved as '12.16.2'" ) ;
557
557
expect ( logSpy ) . toHaveBeenCalledWith ( `Found in cache @ ${ toolPath } ` ) ;
558
558
expect ( cnSpy ) . toHaveBeenCalledWith ( `::add-path::${ toolPath } /bin${ osm . EOL } ` ) ;
@@ -580,13 +580,68 @@ describe('setup-node', () => {
580
580
expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempt to resolve the latest version from manifest...' ) ;
581
581
expect ( warningSpy ) . toHaveBeenCalledWith ( 'LTS version is provided. For LTS versions `check-latest` will be automatically set to true' )
582
582
expect ( dbgSpy ) . toHaveBeenCalledWith ( `LTS alias 'erbium' for Node version 'lts/erbium'` )
583
- expect ( dbgSpy ) . toHaveBeenCalledWith ( `Found LTS release 'erbium ' for Node version 'lts/erbium'` )
583
+ expect ( dbgSpy ) . toHaveBeenCalledWith ( `Found LTS release '12.16.2 ' for Node version 'lts/erbium'` )
584
584
expect ( logSpy ) . toHaveBeenCalledWith ( "Resolved as '12.16.2'" ) ;
585
585
expect ( logSpy ) . toHaveBeenCalledWith ( "Attempting to download 12.16.2..." ) ;
586
586
expect ( logSpy ) . toHaveBeenCalledWith ( `Acquiring 12.16.2 - ${ os . arch } from ${ expectedUrl } ` ) ;
587
587
expect ( logSpy ) . toHaveBeenCalledWith ( 'Extracting ...' ) ;
588
588
expect ( logSpy ) . toHaveBeenCalledWith ( 'Adding to the cache ...' ) ;
589
589
expect ( cnSpy ) . toHaveBeenCalledWith ( `::add-path::${ toolPath } /bin${ osm . EOL } ` ) ;
590
590
} )
591
+
592
+ it ( 'find latest LTS version and resolve it from local cache (lts/*)' , async ( ) => {
593
+ // arrange
594
+ os . platform = 'linux' ;
595
+ os . arch = 'x64' ;
596
+
597
+ inputs [ 'node-version' ] = 'lts/*' ;
598
+ inputs . stable = 'true' ;
599
+
600
+ const toolPath = path . normalize ( '/cache/node/14.0.0/x64' ) ;
601
+ findSpy . mockReturnValue ( toolPath ) ;
602
+
603
+ // act
604
+ await main . run ( ) ;
605
+
606
+ // assert
607
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempt to resolve the latest version from manifest...' ) ;
608
+ expect ( warningSpy ) . toHaveBeenCalledWith ( 'LTS version is provided. For LTS versions `check-latest` will be automatically set to true' )
609
+ expect ( dbgSpy ) . toHaveBeenCalledWith ( `LTS alias '*' for Node version 'lts/*'` )
610
+ expect ( dbgSpy ) . toHaveBeenCalledWith ( `Found LTS release '14.0.0' for Node version 'lts/*'` )
611
+ expect ( logSpy ) . toHaveBeenCalledWith ( "Resolved as '14.0.0'" ) ;
612
+ expect ( logSpy ) . toHaveBeenCalledWith ( `Found in cache @ ${ toolPath } ` ) ;
613
+ expect ( cnSpy ) . toHaveBeenCalledWith ( `::add-path::${ toolPath } /bin${ osm . EOL } ` ) ;
614
+ } ) ;
615
+
616
+ it ( 'find latest LTS version and install it from manifest (lts/*)' , async ( ) => {
617
+ // arrange
618
+ os . platform = 'linux' ;
619
+ os . arch = 'x64' ;
620
+
621
+ inputs [ 'node-version' ] = 'lts/*' ;
622
+ inputs . stable = 'true' ;
623
+
624
+ const toolPath = path . normalize ( '/cache/node/14.0.0/x64' ) ;
625
+ findSpy . mockImplementation ( ( ) => '' ) ;
626
+ dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
627
+ exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
628
+ cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
629
+ const expectedUrl = 'https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz' ;
630
+
631
+ // act
632
+ await main . run ( ) ;
633
+
634
+ // assert
635
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempt to resolve the latest version from manifest...' ) ;
636
+ expect ( warningSpy ) . toHaveBeenCalledWith ( 'LTS version is provided. For LTS versions `check-latest` will be automatically set to true' )
637
+ expect ( dbgSpy ) . toHaveBeenCalledWith ( `LTS alias '*' for Node version 'lts/*'` )
638
+ expect ( dbgSpy ) . toHaveBeenCalledWith ( `Found LTS release '14.0.0' for Node version 'lts/*'` )
639
+ expect ( logSpy ) . toHaveBeenCalledWith ( "Resolved as '14.0.0'" ) ;
640
+ expect ( logSpy ) . toHaveBeenCalledWith ( "Attempting to download 14.0.0..." ) ;
641
+ expect ( logSpy ) . toHaveBeenCalledWith ( `Acquiring 14.0.0 - ${ os . arch } from ${ expectedUrl } ` ) ;
642
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Extracting ...' ) ;
643
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Adding to the cache ...' ) ;
644
+ expect ( cnSpy ) . toHaveBeenCalledWith ( `::add-path::${ toolPath } /bin${ osm . EOL } ` ) ;
645
+ } )
591
646
} )
592
647
} ) ;
0 commit comments