action-gh-release/__tests__/github.test.ts
WÁNG Xuěruì deddb09c64
fix: big file uploads (#562)
* fix: use readableWebStream() to stream asset contents

This allows the uploads to finish without mismatched Content-Length,
likely because the original method implied a wrong body encoding or
something similar. Unfortunately a GitHub server API mock was not
readily available so I had to test manually with a barebones repository.

Fixes: #555
Fixes: #556
Signed-off-by: WANG Xuerui <git@xen0n.name>

* feat: log when each asset is successfully uploaded

Signed-off-by: WANG Xuerui <git@xen0n.name>

* build: refresh dist

Signed-off-by: WANG Xuerui <git@xen0n.name>

* style: format with prettier

Signed-off-by: WANG Xuerui <git@xen0n.name>

---------

Signed-off-by: WANG Xuerui <git@xen0n.name>
2025-01-07 13:42:55 -05:00

24 lines
767 B
TypeScript

import * as assert from "assert";
import { text } from "stream/consumers";
import { mimeOrDefault, asset } from "../src/github";
describe("github", () => {
describe("mimeOrDefault", () => {
it("returns a specific mime for common path", async () => {
assert.equal(mimeOrDefault("foo.tar.gz"), "application/gzip");
});
it("returns default mime for uncommon path", async () => {
assert.equal(mimeOrDefault("foo.uncommon"), "application/octet-stream");
});
});
describe("asset", () => {
it("derives asset info from a path", async () => {
const { name, mime, size } = asset("tests/data/foo/bar.txt");
assert.equal(name, "bar.txt");
assert.equal(mime, "text/plain");
assert.equal(size, 10);
});
});
});