@@ -337,49 +337,43 @@ describe('setup-node', () => {
337
337
expect ( cnSpy ) . toHaveBeenCalledWith ( `::error::${ errMsg } ${ osm . EOL } ` ) ;
338
338
} ) ;
339
339
340
- it ( 'Acquires specified x64 or x86 version of node if no matching version is installed' , async ( ) => {
341
- const toolDir = path . join (
342
- __dirname ,
343
- 'runner' ,
344
- path . join (
345
- Math . random ( )
346
- . toString ( 36 )
347
- . substring ( 7 )
348
- ) ,
349
- 'tools'
350
- ) ;
351
-
352
- os . platform = process . platform ;
353
- const IS_WINDOWS = os . platform === 'win32' ;
354
- for ( const { arch, version} of [
355
- { arch : 'x64' , version : '12.18.3' } ,
356
- { arch : 'x86' , version : '12.18.3' }
340
+ it ( 'Acquires specified architecture of node' , async ( ) => {
341
+ for ( const { arch, version, osSpec} of [
342
+ { arch : 'x86' , version : '12.16.2' , osSpec : 'win32' } ,
343
+ { arch : 'x86' , version : '14.0.0' , osSpec : 'win32' }
357
344
] ) {
358
- nock . cleanAll ( ) ;
359
- const fileExtension = IS_WINDOWS ? '7z' : 'tar.gz' ;
345
+ os . platform = osSpec ;
346
+ os . arch = arch ;
347
+ const fileExtension = os . platform === 'win32' ? '7z' : 'tar.gz' ;
360
348
const platform = {
361
349
linux : 'linux' ,
362
350
darwin : 'darwin' ,
363
351
win32 : 'win'
364
- } [ process . platform ] ;
365
- const fileName = `node-v${ version } -${ platform } -${ arch } .${ fileExtension } ` ;
366
- const pathOnNodeJs = `/dist/v${ version } /${ fileName } ` ;
367
- const scope = nock ( 'nodejs.org' )
368
- . get ( pathOnNodeJs )
369
- . replyWithFile (
370
- 200 ,
371
- path . join ( __dirname , '__fixtures__' , `mock-${ fileName } ` )
372
- ) ;
373
- await im . getNode ( version , true , true , undefined , arch ) ;
374
- const nodeDir = path . join ( toolDir , 'node' , version , arch ) ;
375
-
376
- expect ( scope . isDone ( ) ) . toBe ( true ) ;
377
- expect ( fs . existsSync ( `${ nodeDir } .complete` ) ) . toBe ( true ) ;
378
- if ( IS_WINDOWS ) {
379
- expect ( fs . existsSync ( path . join ( nodeDir , 'node.exe' ) ) ) . toBe ( true ) ;
380
- } else {
381
- expect ( fs . existsSync ( path . join ( nodeDir , 'bin' , 'node' ) ) ) . toBe ( true ) ;
382
- }
352
+ } [ os . platform ] ;
353
+
354
+ inputs [ 'node-version' ] = version ;
355
+ inputs [ 'node-arch' ] = arch ;
356
+ inputs [ 'always-auth' ] = false ;
357
+ inputs [ 'token' ] = 'faketoken' ;
358
+
359
+ let expectedUrl =
360
+ arch === 'x64'
361
+ ? `https://github.com/actions/node-versions/releases/download/${ version } /node-${ version } -${ platform } -${ arch } .zip`
362
+ : `https://nodejs.org/dist/v${ version } /node-v${ version } -${ platform } -${ arch } .${ fileExtension } ` ;
363
+
364
+ // ... but not in the local cache
365
+ findSpy . mockImplementation ( ( ) => '' ) ;
366
+
367
+ dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
368
+ let toolPath = path . normalize ( `/cache/node/${ version } /${ arch } ` ) ;
369
+ exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
370
+ cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
371
+
372
+ await main . run ( ) ;
373
+ expect ( dlSpy ) . toHaveBeenCalled ( ) ;
374
+ expect ( logSpy ) . toHaveBeenCalledWith (
375
+ `Acquiring ${ version } - ${ arch } from ${ expectedUrl } `
376
+ ) ;
383
377
}
384
378
} , 100000 ) ;
385
379
0 commit comments