overload downloadTool to accept destination path (#257)

This commit is contained in:
eric sciple authored and GitHub committed 2019-12-16 11:59:48 -05:00
1 parent 6ef30bf250
commit 24b8c790c3
2 files changed
+53 -9

No files matched your search

+41
View File
@@ -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')