feat: add link module
test / test (push) Failing after 5m41s

This commit is contained in:
2026-11-02 02:35:24 +03:00
parent 7615dbfc48
commit 8fb9b90d6c
11 changed files with 158 additions and 130 deletions
+9 -13
View File
@@ -5,18 +5,14 @@ import { join } from "node:path";
import test from "node:test";
import { download } from "../dist/lib/index.mjs";
const resolveTargetDir = () => mkdtempSync(join(tmpdir(), "test-"));
const TEST_DATA = {
"https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-win.zip": "haxe.exe",
"https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-linux64.tar.gz": "haxe",
"https://home.shmyga.ru/public/test.txt": "test.txt",
const testUrl = async (url, file) => {
const target = mkdtempSync(join(tmpdir(), "test-"));
await download(url, target);
assert(existsSync(join(target, file)));
};
for (const [url, file] of Object.entries(TEST_DATA)) {
test(`Test download: ${url}`, async () => {
const target = resolveTargetDir();
await download(url, target);
assert(existsSync(join(target, file)));
});
}
test("zip", async () => await testUrl("https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-win.zip", "haxe.exe"));
test("tar.gz", async () => await testUrl("https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-linux64.tar.gz", "haxe"));
test("plain", async () => await testUrl("https://home.shmyga.ru/public/test.txt", "test.txt"));