summaryrefslogtreecommitdiff
path: root/cgithub/src/scraper.test.ts
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-01-27 11:23:11 -0500
committerJoe Mou <dev@mou.fo>2026-01-27 12:51:04 -0500
commit04bbba0a7b71f1fb090d3e3a73110a00c36bf765 (patch)
treefdc8e8ed5584cadb3f83735cd8f5e8b48c8304d9 /cgithub/src/scraper.test.ts
parentad2871ca617899aa36a2d85b41974bae9796ace6 (diff)
Propagate GitHub HTTP errors
Render `error.eta` on HTTP error from GitHub. Implemented with Gemini.
Diffstat (limited to 'cgithub/src/scraper.test.ts')
-rw-r--r--cgithub/src/scraper.test.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/cgithub/src/scraper.test.ts b/cgithub/src/scraper.test.ts
index 3784190..adf70ae 100644
--- a/cgithub/src/scraper.test.ts
+++ b/cgithub/src/scraper.test.ts
@@ -1,6 +1,6 @@
import assert from "node:assert";
import { describe, it } from "node:test";
-import { getGitHubBlob, getGitHubRepo, getGitHubTree } from "./scraper.ts";
+import { getGitHubBlob, getGitHubRepo, getGitHubTree, GitHubHTTPError } from "./scraper.ts";
describe("GitHub scraper", () => {
describe("actions/deploy-pages repository", () => {
@@ -67,4 +67,14 @@ describe("GitHub scraper", () => {
assert.match(data.content, /^MIT License\n\n/);
});
});
+
+ describe("error handling", () => {
+ it("should throw for non-existent repository", async () => {
+ await assert.rejects(getGitHubRepo("nosuchowner", "nosuchrepo"), (err) => {
+ assert(err instanceof GitHubHTTPError, "error should be an HTTPError");
+ assert.strictEqual(err.status, 404);
+ return true;
+ });
+ });
+ });
});