@@ -4,9 +4,6 @@ import * as path from 'path'
44import * as core from '../src/core'
55import { HttpClient } from '@actions/http-client'
66import { toCommandProperties } from '../src/utils'
7- import * as uuid from 'uuid'
8-
9- jest . mock ( 'uuid' )
107
118/* eslint-disable @typescript-eslint/unbound-method */
129
@@ -49,11 +46,18 @@ const testEnvVars = {
4946const UUID = '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
5047const DELIMITER = `ghadelimiter_${ UUID } `
5148
49+ const TEMP_DIR = path . join ( __dirname , '_temp' )
50+
5251describe ( '@actions/core' , ( ) => {
5352 beforeAll ( ( ) => {
54- const filePath = path . join ( __dirname , `test` )
53+ const filePath = TEMP_DIR
5554 if ( ! fs . existsSync ( filePath ) ) {
5655 fs . mkdirSync ( filePath )
56+ } else {
57+ // Clear out the temp directory
58+ for ( const file of fs . readdirSync ( filePath ) ) {
59+ fs . unlinkSync ( path . join ( filePath , file ) )
60+ }
5761 }
5862 } )
5963
@@ -63,7 +67,7 @@ describe('@actions/core', () => {
6367 }
6468 process . stdout . write = jest . fn ( )
6569
66- jest . spyOn ( uuid , 'v4 ' ) . mockImplementation ( ( ) => {
70+ jest . spyOn ( crypto , 'randomUUID ' ) . mockImplementation ( ( ) => {
6771 return UUID
6872 } )
6973 } )
@@ -141,7 +145,7 @@ describe('@actions/core', () => {
141145 `Unexpected input: value should not contain the delimiter "${ DELIMITER } "`
142146 )
143147
144- const filePath = path . join ( __dirname , `test/ ${ command } ` )
148+ const filePath = path . join ( TEMP_DIR , command )
145149 fs . unlinkSync ( filePath )
146150 } )
147151
@@ -155,7 +159,7 @@ describe('@actions/core', () => {
155159 `Unexpected input: name should not contain the delimiter "${ DELIMITER } "`
156160 )
157161
158- const filePath = path . join ( __dirname , `test/ ${ command } ` )
162+ const filePath = path . join ( TEMP_DIR , command )
159163 fs . unlinkSync ( filePath )
160164 } )
161165
@@ -347,7 +351,7 @@ describe('@actions/core', () => {
347351 `Unexpected input: value should not contain the delimiter "${ DELIMITER } "`
348352 )
349353
350- const filePath = path . join ( __dirname , `test/ ${ command } ` )
354+ const filePath = path . join ( TEMP_DIR , command )
351355 fs . unlinkSync ( filePath )
352356 } )
353357
@@ -361,7 +365,7 @@ describe('@actions/core', () => {
361365 `Unexpected input: name should not contain the delimiter "${ DELIMITER } "`
362366 )
363367
364- const filePath = path . join ( __dirname , `test/ ${ command } ` )
368+ const filePath = path . join ( TEMP_DIR , command )
365369 fs . unlinkSync ( filePath )
366370 } )
367371
@@ -585,7 +589,7 @@ describe('@actions/core', () => {
585589 `Unexpected input: value should not contain the delimiter "${ DELIMITER } "`
586590 )
587591
588- const filePath = path . join ( __dirname , `test/ ${ command } ` )
592+ const filePath = path . join ( TEMP_DIR , command )
589593 fs . unlinkSync ( filePath )
590594 } )
591595
@@ -599,7 +603,7 @@ describe('@actions/core', () => {
599603 `Unexpected input: name should not contain the delimiter "${ DELIMITER } "`
600604 )
601605
602- const filePath = path . join ( __dirname , `test/ ${ command } ` )
606+ const filePath = path . join ( TEMP_DIR , command )
603607 fs . unlinkSync ( filePath )
604608 } )
605609
@@ -641,15 +645,15 @@ function assertWriteCalls(calls: string[]): void {
641645}
642646
643647function createFileCommandFile ( command : string ) : void {
644- const filePath = path . join ( __dirname , `test /${ command } ` )
648+ const filePath = path . join ( __dirname , `_temp /${ command } ` )
645649 process . env [ `GITHUB_${ command } ` ] = filePath
646650 fs . appendFileSync ( filePath , '' , {
647651 encoding : 'utf8'
648652 } )
649653}
650654
651655function verifyFileCommand ( command : string , expectedContents : string ) : void {
652- const filePath = path . join ( __dirname , `test /${ command } ` )
656+ const filePath = path . join ( __dirname , `_temp /${ command } ` )
653657 const contents = fs . readFileSync ( filePath , 'utf8' )
654658 try {
655659 expect ( contents ) . toEqual ( expectedContents )
0 commit comments