mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-03-15 15:52:36 +08:00
overload downloadTool to accept destination path (#257)
This commit is contained in:
@@ -47,6 +47,47 @@ describe('@actions/tool-cache', function() {
|
||||
expect(fs.statSync(downPath).size).toBe(35)
|
||||
})
|
||||
|
||||
it('downloads a 35 byte file (dest)', async () => {
|
||||
const dest = 'test-download-file'
|
||||
try {
|
||||
const downPath: string = await tc.downloadTool(
|
||||
'http://example.com/bytes/35',
|
||||
dest
|
||||
)
|
||||
|
||||
expect(downPath).toEqual(dest)
|
||||
expect(fs.existsSync(downPath)).toBeTruthy()
|
||||
expect(fs.statSync(downPath).size).toBe(35)
|
||||
} finally {
|
||||
try {
|
||||
await fs.promises.unlink(dest)
|
||||
} catch {
|
||||
// intentionally empty
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it('downloads a 35 byte file (dest requires mkdirp)', async () => {
|
||||
const dest = 'test-download-dir/test-download-file'
|
||||
try {
|
||||
const downPath: string = await tc.downloadTool(
|
||||
'http://example.com/bytes/35',
|
||||
dest
|
||||
)
|
||||
|
||||
expect(downPath).toEqual(dest)
|
||||
expect(fs.existsSync(downPath)).toBeTruthy()
|
||||
expect(fs.statSync(downPath).size).toBe(35)
|
||||
} finally {
|
||||
try {
|
||||
await fs.promises.unlink(dest)
|
||||
await fs.promises.rmdir(path.dirname(dest))
|
||||
} catch {
|
||||
// intentionally empty
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it('downloads a 35 byte file after a redirect', async () => {
|
||||
nock('http://example.com')
|
||||
.get('/redirect-to')
|
||||
|
||||
Reference in New Issue
Block a user