11import { expect , test } from "vitest"
2- import { extractTo , getAssetNames } from "../src/tool"
2+ import { download , extractTo , getAssetNames } from "../src/tool"
33import * as path from "path"
44import * as fs from "fs"
55import { homedir , tmpdir } from "os"
6- import tc from '@actions/tool-cache'
6+
77test ( "getAssetNames" , ( ) => {
88 expect ( getAssetNames ( "deno" , "win32" , "x64" ) ) . toEqual ( [
99 "deno-x86_64-pc-windows-msvc" ,
@@ -23,9 +23,10 @@ test("getAssetNames", () => {
2323test ( "extractTo zip" , async ( ) => {
2424 const url =
2525 "https://github.com/ahaoboy/ansi2/releases/download/v0.2.11/ansi2-x86_64-pc-windows-msvc.zip"
26+ const filePath = path . join ( tmpdir ( ) , "ansi2-x86_64-pc-windows-msvc.zip" )
2627 const testDir = "easy-setup-test"
2728 const installDir = path . join ( homedir ( ) , testDir )
28- const filePath = await tc . downloadTool ( url )
29+ await download ( url , filePath )
2930 extractTo ( filePath , installDir )
3031 const ansi2Path = path . join ( homedir ( ) , testDir , "ansi2.exe" )
3132 expect ( fs . existsSync ( ansi2Path ) ) . toEqual ( true )
@@ -36,9 +37,10 @@ test("extractTo tar.gz", async () => {
3637 if ( process . platform === "win32" ) return
3738 const url =
3839 "https://github.com/ahaoboy/ansi2/releases/download/v0.2.11/ansi2-aarch64-apple-darwin.tar.gz"
40+ const filePath = path . join ( tmpdir ( ) , "ansi2-aarch64-apple-darwin.tar.gz" )
3941 const testDir = "easy-setup-test"
4042 const installDir = path . join ( homedir ( ) , testDir )
41- const filePath = await tc . downloadTool ( url )
43+ await download ( url , filePath )
4244 extractTo ( filePath , installDir )
4345 const ansi2Path = path . join ( homedir ( ) , testDir , "ansi2" )
4446 expect ( fs . existsSync ( ansi2Path ) ) . toEqual ( true )
0 commit comments