summaryrefslogtreecommitdiff
path: root/cgithub/src/scraper.test.ts
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-04-25 13:35:17 -0400
committerJoe Mou <dev@mou.fo>2026-04-28 02:07:40 -0400
commitcfe74db6c177151da3d1bc8549732e3d39448040 (patch)
tree49359a8587e87b2bc857d0a7b7fc1c3c396cde86 /cgithub/src/scraper.test.ts
parentdbe8141dce07559c1e16f17800dfd505b0ecdb46 (diff)
Support redirects
Diffstat (limited to 'cgithub/src/scraper.test.ts')
-rw-r--r--cgithub/src/scraper.test.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/cgithub/src/scraper.test.ts b/cgithub/src/scraper.test.ts
index 4432231..c20a5ff 100644
--- a/cgithub/src/scraper.test.ts
+++ b/cgithub/src/scraper.test.ts
@@ -9,6 +9,7 @@ import {
getGitHubRepo,
getGitHubTree,
GitHubHTTPError,
+ RedirectError,
} from "./scraper.ts";
describe("GitHub scraper", () => {
@@ -245,5 +246,30 @@ describe("GitHub scraper", () => {
return true;
});
});
+
+ it("should redirect when fetching a directory as a blob", async () => {
+ await assert.rejects(
+ getGitHubBlob("badlogic", "pi-mono", "main", "packages/agent"),
+ (err) => {
+ assert(err instanceof RedirectError, "error should be a RedirectError");
+ assert.strictEqual(err.location, "/badlogic/pi-mono/tree/main/packages/agent");
+ return true;
+ },
+ );
+ });
+
+ it("should redirect when fetching a file as a tree", async () => {
+ await assert.rejects(
+ getGitHubTree("badlogic", "pi-mono", "main", "packages/agent/package.json"),
+ (err) => {
+ assert(err instanceof RedirectError, "error should be a RedirectError");
+ assert.strictEqual(
+ err.location,
+ "/badlogic/pi-mono/blob/main/packages/agent/package.json",
+ );
+ return true;
+ },
+ );
+ });
});
});