Previously all assets were being read synchronously into memory, making the action unsuitable for releasing very large assets. Because the client library allows stream body inputs (it just forwards it to the underlying `fetch` implementation), just do it. The idea is also suggested by @enumag in https://github.com/softprops/action-gh-release/issues/353#issuecomment-1793865790. Fixes: #353 Signed-off-by: WANG Xuerui <git@xen0n.name>
25 lines
825 B
TypeScript
25 lines
825 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, data } = asset("tests/data/foo/bar.txt");
|
|
assert.equal(name, "bar.txt");
|
|
assert.equal(mime, "text/plain");
|
|
assert.equal(size, 10);
|
|
assert.equal(await text(data), "release me");
|
|
});
|
|
});
|
|
});
|