@@ -677,215 +677,102 @@ describe('setup-node', () => {
677
677
inputs . stable = 'true' ;
678
678
} ) ;
679
679
680
- it ( 'find latest LTS version and resolve it from local cache (lts/erbium)' , async ( ) => {
681
- // arrange
682
- inputs [ 'node-version' ] = 'lts/erbium' ;
683
-
684
- const toolPath = path . normalize ( '/cache/node/12.16.2/x64' ) ;
685
- findSpy . mockReturnValue ( toolPath ) ;
686
-
687
- // act
688
- await main . run ( ) ;
689
-
690
- // assert
691
- expect ( logSpy ) . toHaveBeenCalledWith (
692
- 'Attempt to resolve LTS alias from manifest...'
693
- ) ;
694
- expect ( dbgSpy ) . toHaveBeenCalledWith (
695
- 'Getting manifest from actions/node-versions@main'
696
- ) ;
697
- expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
698
- expect ( dbgSpy ) . toHaveBeenCalledWith (
699
- `LTS alias 'erbium' for Node version 'lts/erbium'`
700
- ) ;
701
- expect ( dbgSpy ) . toHaveBeenCalledWith (
702
- `Found LTS release '12.16.2' for Node version 'lts/erbium'`
703
- ) ;
704
- expect ( logSpy ) . toHaveBeenCalledWith ( `Found in cache @ ${ toolPath } ` ) ;
705
- expect ( cnSpy ) . toHaveBeenCalledWith (
706
- `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
707
- ) ;
708
- } ) ;
709
-
710
- it ( 'find latest LTS version and install it from manifest (lts/erbium)' , async ( ) => {
711
- // arrange
712
- inputs [ 'node-version' ] = 'lts/erbium' ;
713
-
714
- const toolPath = path . normalize ( '/cache/node/12.16.2/x64' ) ;
715
- findSpy . mockImplementation ( ( ) => '' ) ;
716
- dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
717
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
718
- cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
719
- const expectedUrl =
720
- 'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz' ;
721
-
722
- // act
723
- await main . run ( ) ;
724
-
725
- // assert
726
- expect ( logSpy ) . toHaveBeenCalledWith (
727
- 'Attempt to resolve LTS alias from manifest...'
728
- ) ;
729
- expect ( dbgSpy ) . toHaveBeenCalledWith (
730
- 'Getting manifest from actions/node-versions@main'
731
- ) ;
732
- expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
733
- expect ( dbgSpy ) . toHaveBeenCalledWith (
734
- `LTS alias 'erbium' for Node version 'lts/erbium'`
735
- ) ;
736
- expect ( dbgSpy ) . toHaveBeenCalledWith (
737
- `Found LTS release '12.16.2' for Node version 'lts/erbium'`
738
- ) ;
739
- expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempting to download 12...' ) ;
740
- expect ( logSpy ) . toHaveBeenCalledWith (
741
- `Acquiring 12.16.2 - ${ os . arch } from ${ expectedUrl } `
742
- ) ;
743
- expect ( logSpy ) . toHaveBeenCalledWith ( 'Extracting ...' ) ;
744
- expect ( logSpy ) . toHaveBeenCalledWith ( 'Adding to the cache ...' ) ;
745
- expect ( cnSpy ) . toHaveBeenCalledWith (
746
- `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
747
- ) ;
748
- } ) ;
749
-
750
- it ( 'find latest LTS version and resolve it from local cache (lts/*)' , async ( ) => {
751
- // arrange
752
- inputs [ 'node-version' ] = 'lts/*' ;
753
-
754
- const toolPath = path . normalize ( '/cache/node/14.0.0/x64' ) ;
755
- findSpy . mockReturnValue ( toolPath ) ;
756
-
757
- // act
758
- await main . run ( ) ;
759
-
760
- // assert
761
- expect ( logSpy ) . toHaveBeenCalledWith (
762
- 'Attempt to resolve LTS alias from manifest...'
763
- ) ;
764
- expect ( dbgSpy ) . toHaveBeenCalledWith (
765
- 'Getting manifest from actions/node-versions@main'
766
- ) ;
767
- expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
768
- expect ( dbgSpy ) . toHaveBeenCalledWith (
769
- `LTS alias '*' for Node version 'lts/*'`
770
- ) ;
771
- expect ( dbgSpy ) . toHaveBeenCalledWith (
772
- `Found LTS release '14.0.0' for Node version 'lts/*'`
773
- ) ;
774
- expect ( logSpy ) . toHaveBeenCalledWith ( `Found in cache @ ${ toolPath } ` ) ;
775
- expect ( cnSpy ) . toHaveBeenCalledWith (
776
- `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
777
- ) ;
778
- } ) ;
779
-
780
- it ( 'find latest LTS version and install it from manifest (lts/*)' , async ( ) => {
781
- // arrange
782
- inputs [ 'node-version' ] = 'lts/*' ;
783
-
784
- const toolPath = path . normalize ( '/cache/node/14.0.0/x64' ) ;
785
- findSpy . mockImplementation ( ( ) => '' ) ;
786
- dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
787
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
788
- cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
789
- const expectedUrl =
790
- 'https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz' ;
791
-
792
- // act
793
- await main . run ( ) ;
794
-
795
- // assert
796
- expect ( logSpy ) . toHaveBeenCalledWith (
797
- 'Attempt to resolve LTS alias from manifest...'
798
- ) ;
799
- expect ( dbgSpy ) . toHaveBeenCalledWith (
800
- 'Getting manifest from actions/node-versions@main'
801
- ) ;
802
- expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
803
- expect ( dbgSpy ) . toHaveBeenCalledWith (
804
- `LTS alias '*' for Node version 'lts/*'`
805
- ) ;
806
- expect ( dbgSpy ) . toHaveBeenCalledWith (
807
- `Found LTS release '14.0.0' for Node version 'lts/*'`
808
- ) ;
809
- expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempting to download 14...' ) ;
810
- expect ( logSpy ) . toHaveBeenCalledWith (
811
- `Acquiring 14.0.0 - ${ os . arch } from ${ expectedUrl } `
812
- ) ;
813
- expect ( logSpy ) . toHaveBeenCalledWith ( 'Extracting ...' ) ;
814
- expect ( logSpy ) . toHaveBeenCalledWith ( 'Adding to the cache ...' ) ;
815
- expect ( cnSpy ) . toHaveBeenCalledWith (
816
- `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
817
- ) ;
818
- } ) ;
819
-
820
- it ( 'find latest LTS version and resolve it from local cache (lts/-1)' , async ( ) => {
821
- // arrange
822
- inputs [ 'node-version' ] = 'lts/-1' ;
823
-
824
- const toolPath = path . normalize ( '/cache/node/12.16.2/x64' ) ;
825
- findSpy . mockReturnValue ( toolPath ) ;
826
-
827
- // act
828
- await main . run ( ) ;
680
+ it . each ( [
681
+ [ 'erbium' , '12.16.2' ] ,
682
+ [ '*' , '14.0.0' ] ,
683
+ [ '-1' , '12.16.2' ]
684
+ ] ) (
685
+ 'find latest LTS version and resolve it from local cache (lts/%s)' ,
686
+ async ( lts , expectedVersion ) => {
687
+ // arrange
688
+ inputs [ 'node-version' ] = `lts/${ lts } ` ;
689
+
690
+ const toolPath = path . normalize ( `/cache/node/${ expectedVersion } /x64` ) ;
691
+ findSpy . mockReturnValue ( toolPath ) ;
829
692
830
- // assert
831
- expect ( logSpy ) . toHaveBeenCalledWith (
832
- 'Attempt to resolve LTS alias from manifest...'
833
- ) ;
834
- expect ( dbgSpy ) . toHaveBeenCalledWith (
835
- 'Getting manifest from actions/node-versions@main'
836
- ) ;
837
- expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
838
- expect ( dbgSpy ) . toHaveBeenCalledWith (
839
- `LTS alias '-1' for Node version 'lts/-1'`
840
- ) ;
841
- expect ( dbgSpy ) . toHaveBeenCalledWith (
842
- `Found LTS release '12.16.2' for Node version 'lts/-1'`
843
- ) ;
844
- expect ( logSpy ) . toHaveBeenCalledWith ( `Found in cache @ ${ toolPath } ` ) ;
845
- expect ( cnSpy ) . toHaveBeenCalledWith (
846
- `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
847
- ) ;
848
- } ) ;
693
+ // act
694
+ await main . run ( ) ;
849
695
850
- it ( 'find latest LTS version and install it from manifest (lts/-1)' , async ( ) => {
851
- // arrange
852
- inputs [ 'node-version' ] = 'lts/-1' ;
696
+ // assert
697
+ expect ( logSpy ) . toHaveBeenCalledWith (
698
+ 'Attempt to resolve LTS alias from manifest...'
699
+ ) ;
700
+ expect ( dbgSpy ) . toHaveBeenCalledWith (
701
+ 'Getting manifest from actions/node-versions@main'
702
+ ) ;
703
+ expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
704
+ expect ( dbgSpy ) . toHaveBeenCalledWith (
705
+ `LTS alias '${ lts } ' for Node version 'lts/${ lts } '`
706
+ ) ;
707
+ expect ( dbgSpy ) . toHaveBeenCalledWith (
708
+ `Found LTS release '${ expectedVersion } ' for Node version 'lts/${ lts } '`
709
+ ) ;
710
+ expect ( logSpy ) . toHaveBeenCalledWith ( `Found in cache @ ${ toolPath } ` ) ;
711
+ expect ( cnSpy ) . toHaveBeenCalledWith (
712
+ `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
713
+ ) ;
714
+ }
715
+ ) ;
853
716
854
- const toolPath = path . normalize ( '/cache/node/12.16.2/x64' ) ;
855
- findSpy . mockImplementation ( ( ) => '' ) ;
856
- dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
857
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
858
- cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
859
- const expectedUrl =
860
- 'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz' ;
717
+ it . each ( [
718
+ [
719
+ 'erbium' ,
720
+ '12.16.2' ,
721
+ 'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz'
722
+ ] ,
723
+ [
724
+ '*' ,
725
+ '14.0.0' ,
726
+ 'https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz'
727
+ ] ,
728
+ [
729
+ '-1' ,
730
+ '12.16.2' ,
731
+ 'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz'
732
+ ]
733
+ ] ) (
734
+ 'find latest LTS version and install it from manifest (lts/%s)' ,
735
+ async ( lts , expectedVersion , expectedUrl ) => {
736
+ // arrange
737
+ inputs [ 'node-version' ] = `lts/${ lts } ` ;
738
+
739
+ const toolPath = path . normalize ( `/cache/node/${ expectedVersion } /x64` ) ;
740
+ findSpy . mockImplementation ( ( ) => '' ) ;
741
+ dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
742
+ exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
743
+ cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
744
+ const expectedMajor = expectedVersion . split ( '.' ) [ 0 ] ;
861
745
862
- // act
863
- await main . run ( ) ;
746
+ // act
747
+ await main . run ( ) ;
864
748
865
- // assert
866
- expect ( logSpy ) . toHaveBeenCalledWith (
867
- 'Attempt to resolve LTS alias from manifest...'
868
- ) ;
869
- expect ( dbgSpy ) . toHaveBeenCalledWith (
870
- 'Getting manifest from actions/node-versions@main'
871
- ) ;
872
- expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
873
- expect ( dbgSpy ) . toHaveBeenCalledWith (
874
- `LTS alias '-1' for Node version 'lts/-1'`
875
- ) ;
876
- expect ( dbgSpy ) . toHaveBeenCalledWith (
877
- `Found LTS release '12.16.2' for Node version 'lts/-1'`
878
- ) ;
879
- expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempting to download 12...' ) ;
880
- expect ( logSpy ) . toHaveBeenCalledWith (
881
- `Acquiring 12.16.2 - ${ os . arch } from ${ expectedUrl } `
882
- ) ;
883
- expect ( logSpy ) . toHaveBeenCalledWith ( 'Extracting ...' ) ;
884
- expect ( logSpy ) . toHaveBeenCalledWith ( 'Adding to the cache ...' ) ;
885
- expect ( cnSpy ) . toHaveBeenCalledWith (
886
- `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
887
- ) ;
888
- } ) ;
749
+ // assert
750
+ expect ( logSpy ) . toHaveBeenCalledWith (
751
+ 'Attempt to resolve LTS alias from manifest...'
752
+ ) ;
753
+ expect ( dbgSpy ) . toHaveBeenCalledWith (
754
+ 'Getting manifest from actions/node-versions@main'
755
+ ) ;
756
+ expect ( dbgSpy ) . not . toHaveBeenCalledWith ( 'No manifest cached' ) ;
757
+ expect ( dbgSpy ) . toHaveBeenCalledWith (
758
+ `LTS alias '${ lts } ' for Node version 'lts/${ lts } '`
759
+ ) ;
760
+ expect ( dbgSpy ) . toHaveBeenCalledWith (
761
+ `Found LTS release '${ expectedVersion } ' for Node version 'lts/${ lts } '`
762
+ ) ;
763
+ expect ( logSpy ) . toHaveBeenCalledWith (
764
+ `Attempting to download ${ expectedMajor } ...`
765
+ ) ;
766
+ expect ( logSpy ) . toHaveBeenCalledWith (
767
+ `Acquiring ${ expectedVersion } - ${ os . arch } from ${ expectedUrl } `
768
+ ) ;
769
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Extracting ...' ) ;
770
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Adding to the cache ...' ) ;
771
+ expect ( cnSpy ) . toHaveBeenCalledWith (
772
+ `::add-path::${ path . join ( toolPath , 'bin' ) } ${ osm . EOL } `
773
+ ) ;
774
+ }
775
+ ) ;
889
776
890
777
it ( 'fail with unable to parse LTS alias (lts/)' , async ( ) => {
891
778
// arrange
0 commit comments