Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tool-cache.test.ts
  • Loading branch information
luketomlinson committed May 19, 2021
commit a00d1ad97a3a98ac4e2ba859751cb9023a668211
21 changes: 17 additions & 4 deletions packages/tool-cache/__tests__/tool-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,19 @@ describe('@actions/tool-cache', function() {
const _tgzFile: string = path.join(tempDir, 'test.tar.gz')
await io.cp(path.join(__dirname, 'data', 'test.tar.gz'), _tgzFile)


//Create file to overwrite
const destDir = path.join(__dirname, 'extract-dest')
await io.rmRF(destDir)
await io.mkdirP(destDir)
fs.writeFileSync(path.join(destDir, 'file.txt'), 'overwriteMe')


// extract/cache
const extPath: string = await tc.extractTar(_tgzFile)
const extPath: string = await tc.extractTar(_tgzFile, destDir)
await tc.cacheDir(extPath, 'my-tgz-contents', '1.1.0')
const toolPath: string = tc.find('my-tgz-contents', '1.1.0')

fs.writeFileSync(path.join(tempDir, 'file.txt'), 'overwriteMe')

expect(fs.existsSync(toolPath)).toBeTruthy()
expect(fs.existsSync(`${toolPath}.complete`)).toBeTruthy()
Expand Down Expand Up @@ -525,7 +532,7 @@ describe('@actions/tool-cache', function() {
// copy the .tar.gz file to the test dir
const _tgzFile: string = path.join(tempDir, 'test.tar.gz')
await io.cp(path.join(__dirname, 'data', 'test.tar.gz'), _tgzFile)
fs.writeFileSync(path.join(tempDir, 'file.txt'), 'overwriteMe')
fs.writeFileSync(path.join(destDir, 'file.txt'), 'overwriteMe')

// extract/cache
const extPath: string = await tc.extractTar(_tgzFile, destDir)
Expand Down Expand Up @@ -559,8 +566,14 @@ describe('@actions/tool-cache', function() {
const _txzFile: string = path.join(tempDir, 'test.tar.xz')
await io.cp(path.join(__dirname, 'data', 'test.tar.xz'), _txzFile)

//Create file to overwrite
const destDir = path.join(__dirname, 'extract-dest')
await io.rmRF(destDir)
await io.mkdirP(destDir)
fs.writeFileSync(path.join(destDir, 'file.txt'), 'overwriteMe')

// extract/cache
const extPath: string = await tc.extractTar(_txzFile, undefined, 'x')
const extPath: string = await tc.extractTar(_txzFile, destDir, 'x')
await tc.cacheDir(extPath, 'my-txz-contents', '1.1.0')
const toolPath: string = tc.find('my-txz-contents', '1.1.0')

Expand Down