@@ -77,9 +77,9 @@ describe('setup-node', () => {
7777 authSpy . mockImplementation ( ( ) => { } ) ;
7878
7979 // gets
80- getManifestSpy . mockImplementation (
81- ( ) => < tc . IToolRelease [ ] > nodeTestManifest
82- ) ;
80+ getManifestSpy . mockImplementation ( ( ) => [
81+ ... ( < tc . IToolRelease [ ] > nodeTestManifest )
82+ ] ) ;
8383 getDistSpy . mockImplementation ( ( ) => < im . INodeVersion > nodeTestDist ) ;
8484
8585 // writes
@@ -839,6 +839,76 @@ describe('setup-node', () => {
839839 ) ;
840840 } ) ;
841841
842+ it ( 'find latest LTS version and resolve it from local cache (lts/-2)' , async ( ) => {
843+ // arrange
844+ inputs [ 'node-version' ] = 'lts/-2' ;
845+
846+ const toolPath = path . normalize ( '/cache/node/12.16.2/x64' ) ;
847+ findSpy . mockReturnValue ( toolPath ) ;
848+
849+ // act
850+ await main . run ( ) ;
851+
852+ // assert
853+ expect ( logSpy ) . toHaveBeenCalledWith (
854+ 'Attempt to resolve LTS alias from manifest...'
855+ ) ;
856+ expect ( dbgSpy ) . toHaveBeenCalledWith (
857+ 'Getting manifest from actions/node-versions@main'
858+ ) ;
859+ expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
860+ expect ( dbgSpy ) . toHaveBeenCalledWith (
861+ `LTS alias '-2' for Node version 'lts/-2'`
862+ ) ;
863+ expect ( dbgSpy ) . toHaveBeenCalledWith (
864+ `Found LTS release '12.16.2' for Node version 'lts/-2'`
865+ ) ;
866+ expect ( logSpy ) . toHaveBeenCalledWith ( `Found in cache @ ${ toolPath } ` ) ;
867+ expect ( cnSpy ) . toHaveBeenCalledWith (
868+ `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
869+ ) ;
870+ } ) ;
871+
872+ it ( 'find latest LTS version and install it from manifest (lts/-2)' , async ( ) => {
873+ // arrange
874+ inputs [ 'node-version' ] = 'lts/-2' ;
875+
876+ const toolPath = path . normalize ( '/cache/node/12.16.2/x64' ) ;
877+ findSpy . mockImplementation ( ( ) => '' ) ;
878+ dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
879+ exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
880+ cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
881+ const expectedUrl =
882+ 'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz' ;
883+
884+ // act
885+ await main . run ( ) ;
886+
887+ // assert
888+ expect ( logSpy ) . toHaveBeenCalledWith (
889+ 'Attempt to resolve LTS alias from manifest...'
890+ ) ;
891+ expect ( dbgSpy ) . toHaveBeenCalledWith (
892+ 'Getting manifest from actions/node-versions@main'
893+ ) ;
894+ expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
895+ expect ( dbgSpy ) . toHaveBeenCalledWith (
896+ `LTS alias '-2' for Node version 'lts/-2'`
897+ ) ;
898+ expect ( dbgSpy ) . toHaveBeenCalledWith (
899+ `Found LTS release '12.16.2' for Node version 'lts/-2'`
900+ ) ;
901+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempting to download 12...' ) ;
902+ expect ( logSpy ) . toHaveBeenCalledWith (
903+ `Acquiring 12.16.2 - ${ os . arch } from ${ expectedUrl } `
904+ ) ;
905+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Extracting ...' ) ;
906+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Adding to the cache ...' ) ;
907+ expect ( cnSpy ) . toHaveBeenCalledWith (
908+ `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
909+ ) ;
910+ } ) ;
911+
842912 it ( 'fail with unable to parse LTS alias (lts/)' , async ( ) => {
843913 // arrange
844914 inputs [ 'node-version' ] = 'lts/' ;
0 commit comments