Something went wrong. Try again.
Your thinking partner.
Something went wrong. Try again.
1234567891011121314151617181920212223import { expect, test } from "bun:test";import { createHash } from "node:crypto";import { parseReleaseArgs, verifySavedArtifact } from "./release-android-local";
test("local releases accept a stable version and one explicit mode", () => { expect(parseReleaseArgs(["--help"])).toBeNull(); expect(parseReleaseArgs(["v0.1.6"])).toEqual({ tag: "v0.1.6", buildOnly: false, publishOnly: false }); expect(parseReleaseArgs(["v0.1.6", "--build-only"])?.buildOnly).toBe(true); expect(parseReleaseArgs(["v0.1.6", "--publish-only"])?.publishOnly).toBe(true); for (const args of [[], ["v0.1.6", "--force"], ["v0.1.6", "--build-only", "--publish-only"], ["main"], ["v0.1.6-beta"]]) expect(() => parseReleaseArgs(args)).toThrow();});
test("publication rejects an APK from a different version, commit, or modified file", () => { const bytes = new Uint8Array([1, 2, 3]); const manifest = { tag: "v0.1.6", commit: "a".repeat(40), sha256: createHash("sha256").update(bytes).digest("hex") }; expect(() => verifySavedArtifact(manifest, manifest.tag, manifest.commit, bytes)).not.toThrow(); expect(() => verifySavedArtifact(manifest, "v0.1.7", manifest.commit, bytes)).toThrow(); expect(() => verifySavedArtifact(manifest, manifest.tag, "b".repeat(40), bytes)).toThrow(); expect(() => verifySavedArtifact(manifest, manifest.tag, manifest.commit, new Uint8Array([4]))).toThrow(); expect(() => verifySavedArtifact(null, manifest.tag, manifest.commit, bytes)).toThrow();});