mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-08-22 03:18:54 +08:00
fix: paginate GitHub Actions MCP responses (#1629)
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import type { Octokit } from "@octokit/rest";
|
||||
import {
|
||||
listWorkflowJobs,
|
||||
listWorkflowRuns,
|
||||
} from "../src/mcp/github-actions-pagination";
|
||||
|
||||
function createPaginatedClient<T>(pages: T[][]) {
|
||||
const request = async () => ({ data: pages[0] });
|
||||
const client = {
|
||||
actions: {
|
||||
listWorkflowRunsForRepo: request,
|
||||
listJobsForWorkflowRun: request,
|
||||
},
|
||||
paginate: async () => pages.flat(),
|
||||
} as unknown as Octokit;
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
describe("GitHub Actions pagination", () => {
|
||||
test("returns workflow runs from every page", async () => {
|
||||
const firstPage = [{ id: 1 }, { id: 2 }];
|
||||
const secondPage = [{ id: 3 }];
|
||||
const client = createPaginatedClient([firstPage, secondPage]);
|
||||
|
||||
const runs = await listWorkflowRuns(client, {
|
||||
owner: "owner",
|
||||
repo: "repo",
|
||||
head_sha: "sha",
|
||||
});
|
||||
|
||||
expect(runs.map((run) => run.id)).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
test("returns workflow jobs from every page", async () => {
|
||||
const firstPage = [{ id: 1 }, { id: 2 }];
|
||||
const secondPage = [{ id: 3 }];
|
||||
const client = createPaginatedClient([firstPage, secondPage]);
|
||||
|
||||
const jobs = await listWorkflowJobs(client, {
|
||||
owner: "owner",
|
||||
repo: "repo",
|
||||
run_id: 123,
|
||||
});
|
||||
|
||||
expect(jobs.map((job) => job.id)).toEqual([1, 2, 3]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user