@@ -20,14 +20,15 @@ describe('setup-go', () => {
20
20
21
21
let inSpy : jest . SpyInstance ;
22
22
let getBooleanInputSpy : jest . SpyInstance ;
23
+ let exportVarSpy : jest . SpyInstance ;
23
24
let findSpy : jest . SpyInstance ;
24
25
let cnSpy : jest . SpyInstance ;
25
26
let logSpy : jest . SpyInstance ;
26
27
let getSpy : jest . SpyInstance ;
27
28
let platSpy : jest . SpyInstance ;
28
29
let archSpy : jest . SpyInstance ;
29
30
let dlSpy : jest . SpyInstance ;
30
- let exSpy : jest . SpyInstance ;
31
+ let extractTarSpy : jest . SpyInstance ;
31
32
let cacheSpy : jest . SpyInstance ;
32
33
let dbgSpy : jest . SpyInstance ;
33
34
let whichSpy : jest . SpyInstance ;
@@ -49,7 +50,8 @@ describe('setup-go', () => {
49
50
inSpy . mockImplementation ( name => inputs [ name ] ) ;
50
51
getBooleanInputSpy = jest . spyOn ( core , 'getBooleanInput' ) ;
51
52
getBooleanInputSpy . mockImplementation ( name => inputs [ name ] ) ;
52
- exSpy = jest . spyOn ( core , 'exportVariable' ) ;
53
+ exportVarSpy = jest . spyOn ( core , 'exportVariable' ) ;
54
+ extractTarSpy = jest . spyOn ( core , 'exportVariable' ) ;
53
55
54
56
// node
55
57
os = { } ;
@@ -62,7 +64,7 @@ describe('setup-go', () => {
62
64
// @actions /tool-cache
63
65
findSpy = jest . spyOn ( tc , 'find' ) ;
64
66
dlSpy = jest . spyOn ( tc , 'downloadTool' ) ;
65
- exSpy = jest . spyOn ( tc , 'extractTar' ) ;
67
+ extractTarSpy = jest . spyOn ( tc , 'extractTar' ) ;
66
68
cacheSpy = jest . spyOn ( tc , 'cacheDir' ) ;
67
69
getSpy = jest . spyOn ( im , 'getVersionsDist' ) ;
68
70
getManifestSpy = jest . spyOn ( tc , 'getManifestFromRepo' ) ;
@@ -231,22 +233,41 @@ describe('setup-go', () => {
231
233
expect ( logSpy ) . toHaveBeenCalledWith ( `Setup go version spec 1.13.0` ) ;
232
234
} ) ;
233
235
234
- it ( 'does not export any varibles ' , async ( ) => {
236
+ it ( 'does not export any variables for Go versions >=1.9 ' , async ( ) => {
235
237
inputs [ 'go-version' ] = '1.13.0' ;
236
238
inSpy . mockImplementation ( name => inputs [ name ] ) ;
237
239
238
240
let toolPath = path . normalize ( '/cache/go/1.13.0/x64' ) ;
239
241
findSpy . mockImplementation ( ( ) => toolPath ) ;
240
242
241
- let vars = { } as any ;
242
- exSpy . mockImplementation ( async ( name , val ) => {
243
+ let vars : { [ key : string ] : string ; } = { } ;
244
+ exportVarSpy . mockImplementation ( ( name : string , val : string ) => {
243
245
vars [ name ] = val ;
244
246
} ) ;
245
247
246
248
await main . run ( ) ;
247
249
expect ( vars ) . toStrictEqual ( { } ) ;
248
250
} ) ;
249
251
252
+ it ( 'exports GOROOT for Go versions <1.9' , async ( ) => {
253
+ inputs [ 'go-version' ] = '1.8' ;
254
+ inSpy . mockImplementation ( name => inputs [ name ] ) ;
255
+
256
+ let toolPath = path . normalize ( '/cache/go/1.8.0/x64' ) ;
257
+ findSpy . mockImplementation ( ( ) => toolPath ) ;
258
+
259
+ let vars : { [ key : string ] : string ; } = { } ;
260
+ exportVarSpy . mockImplementation ( ( name : string , val : string ) => {
261
+ vars [ name ] = val ;
262
+ } ) ;
263
+
264
+ await main . run ( ) ;
265
+ expect ( vars ) . toStrictEqual ( {
266
+ "GOROOT" : toolPath
267
+ } ) ;
268
+ } ) ;
269
+
270
+
250
271
it ( 'finds a version of go already in the cache' , async ( ) => {
251
272
inputs [ 'go-version' ] = '1.13.0' ;
252
273
@@ -288,14 +309,14 @@ describe('setup-go', () => {
288
309
findSpy . mockImplementation ( ( ) => '' ) ;
289
310
dlSpy . mockImplementation ( ( ) => '/some/temp/path' ) ;
290
311
let toolPath = path . normalize ( '/cache/go/1.13.0/x64' ) ;
291
- exSpy . mockImplementation ( ( ) => '/some/other/temp/path' ) ;
312
+ extractTarSpy . mockImplementation ( ( ) => '/some/other/temp/path' ) ;
292
313
cacheSpy . mockImplementation ( ( ) => toolPath ) ;
293
314
await main . run ( ) ;
294
315
295
316
let expPath = path . join ( toolPath , 'bin' ) ;
296
317
297
318
expect ( dlSpy ) . toHaveBeenCalled ( ) ;
298
- expect ( exSpy ) . toHaveBeenCalled ( ) ;
319
+ expect ( extractTarSpy ) . toHaveBeenCalled ( ) ;
299
320
expect ( cnSpy ) . toHaveBeenCalledWith ( `::add-path::${ expPath } ${ osm . EOL } ` ) ;
300
321
} ) ;
301
322
@@ -330,15 +351,15 @@ describe('setup-go', () => {
330
351
331
352
dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
332
353
let toolPath = path . normalize ( '/cache/go/1.12.16/x64' ) ;
333
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
354
+ extractTarSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
334
355
cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
335
356
336
357
await main . run ( ) ;
337
358
338
359
let expPath = path . join ( toolPath , 'bin' ) ;
339
360
340
361
expect ( dlSpy ) . toHaveBeenCalled ( ) ;
341
- expect ( exSpy ) . toHaveBeenCalled ( ) ;
362
+ expect ( extractTarSpy ) . toHaveBeenCalled ( ) ;
342
363
expect ( logSpy ) . not . toHaveBeenCalledWith (
343
364
'Not found in manifest. Falling back to download directly from Go'
344
365
) ;
@@ -367,15 +388,15 @@ describe('setup-go', () => {
367
388
368
389
dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
369
390
let toolPath = path . normalize ( '/cache/go/1.12.17/x64' ) ;
370
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
391
+ extractTarSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
371
392
cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
372
393
373
394
await main . run ( ) ;
374
395
375
396
let expPath = path . join ( toolPath , 'bin' ) ;
376
397
377
398
expect ( dlSpy ) . toHaveBeenCalled ( ) ;
378
- expect ( exSpy ) . toHaveBeenCalled ( ) ;
399
+ expect ( extractTarSpy ) . toHaveBeenCalled ( ) ;
379
400
expect ( logSpy ) . not . toHaveBeenCalledWith (
380
401
'Not found in manifest. Falling back to download directly from Go'
381
402
) ;
@@ -404,7 +425,7 @@ describe('setup-go', () => {
404
425
405
426
dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
406
427
let toolPath = path . normalize ( '/cache/go/1.12.14/x64' ) ;
407
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
428
+ extractTarSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
408
429
cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
409
430
410
431
await main . run ( ) ;
@@ -415,7 +436,7 @@ describe('setup-go', () => {
415
436
expect ( logSpy ) . toHaveBeenCalledWith ( 'Attempting to download 1.12.14...' ) ;
416
437
expect ( dlSpy ) . toHaveBeenCalled ( ) ;
417
438
expect ( logSpy ) . toHaveBeenCalledWith ( 'matching 1.12.14...' ) ;
418
- expect ( exSpy ) . toHaveBeenCalled ( ) ;
439
+ expect ( extractTarSpy ) . toHaveBeenCalled ( ) ;
419
440
expect ( logSpy ) . toHaveBeenCalledWith (
420
441
'Not found in manifest. Falling back to download directly from Go'
421
442
) ;
@@ -617,7 +638,7 @@ describe('setup-go', () => {
617
638
const toolPath = path . normalize ( '/cache/go/1.16.1/x64' ) ;
618
639
findSpy . mockReturnValue ( toolPath ) ;
619
640
dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
620
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
641
+ extractTarSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
621
642
cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
622
643
623
644
await main . run ( ) ;
@@ -639,7 +660,7 @@ describe('setup-go', () => {
639
660
findSpy . mockImplementation ( ( ) => '' ) ;
640
661
dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
641
662
const toolPath = path . normalize ( '/cache/go/1.17.5/x64' ) ;
642
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
663
+ extractTarSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
643
664
cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
644
665
const expectedUrl =
645
666
'https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz' ;
@@ -680,15 +701,15 @@ describe('setup-go', () => {
680
701
681
702
dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
682
703
let toolPath = path . normalize ( '/cache/go/1.13.7/x64' ) ;
683
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
704
+ extractTarSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
684
705
cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
685
706
686
707
await main . run ( ) ;
687
708
688
709
let expPath = path . join ( toolPath , 'bin' ) ;
689
710
690
711
expect ( dlSpy ) . toHaveBeenCalled ( ) ;
691
- expect ( exSpy ) . toHaveBeenCalled ( ) ;
712
+ expect ( extractTarSpy ) . toHaveBeenCalled ( ) ;
692
713
expect ( logSpy ) . toHaveBeenCalledWith (
693
714
'Attempting to resolve the latest version from the manifest...'
694
715
) ;
@@ -722,7 +743,7 @@ describe('setup-go', () => {
722
743
723
744
dlSpy . mockImplementation ( async ( ) => '/some/temp/path' ) ;
724
745
let toolPath = path . normalize ( '/cache/go/1.13.7/x64' ) ;
725
- exSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
746
+ extractTarSpy . mockImplementation ( async ( ) => '/some/other/temp/path' ) ;
726
747
cacheSpy . mockImplementation ( async ( ) => toolPath ) ;
727
748
728
749
await main . run ( ) ;
@@ -733,7 +754,7 @@ describe('setup-go', () => {
733
754
`Failed to resolve version ${ versionSpec } from manifest`
734
755
) ;
735
756
expect ( dlSpy ) . toHaveBeenCalled ( ) ;
736
- expect ( exSpy ) . toHaveBeenCalled ( ) ;
757
+ expect ( extractTarSpy ) . toHaveBeenCalled ( ) ;
737
758
expect ( logSpy ) . toHaveBeenCalledWith (
738
759
'Attempting to resolve the latest version from the manifest...'
739
760
) ;
0 commit comments