Skip to content

Commit 06344e2

Browse files
henrymercerCopilot
andcommitted
Stub nightly release listing directly
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 07dc949 commit 06344e2

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

‎src/setup-codeql.test.ts‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,29 @@ function stubHostedNightly(tagName: string) {
6969
available: true,
7070
foundZstdBinary: true,
7171
});
72-
const fetchRelease = sinon
73-
.stub<Parameters<typeof fetch>, ReturnType<typeof fetch>>()
74-
.rejects(new Error("Unexpected API request in nightly bundle test"));
75-
fetchRelease
76-
.withArgs(
77-
"https://api.github.com/repos/dsp-testing/codeql-cli-nightlies/releases?per_page=1&page=1&prerelease=true",
78-
sinon.match({ method: "GET" }),
79-
)
80-
.callsFake(
81-
async () =>
82-
new Response(JSON.stringify([{ tag_name: tagName }]), {
83-
headers: { "content-type": "application/json" },
84-
}),
85-
);
8672
const client = github.getOctokit("123", {
87-
request: { fetch: fetchRelease },
73+
request: {
74+
fetch: async () => {
75+
throw new Error("Unexpected API request in nightly bundle test");
76+
},
77+
},
8878
});
79+
const listReleases = sinon
80+
.stub(client.rest.repos, "listReleases")
81+
.rejects(new Error("Unexpected release request in nightly bundle test"));
82+
listReleases
83+
.withArgs({
84+
owner: "dsp-testing",
85+
repo: "codeql-cli-nightlies",
86+
per_page: 1,
87+
page: 1,
88+
prerelease: true,
89+
})
90+
.resolves({
91+
data: [{ tag_name: tagName }],
92+
} as Awaited<ReturnType<typeof client.rest.repos.listReleases>>);
8993
sinon.stub(api, "getApiClient").value(() => client);
90-
return fetchRelease;
94+
return listReleases;
9195
}
9296

9397
test.serial("parse codeql bundle url version", (t) => {

0 commit comments

Comments
 (0)