Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(github): revalidate pull request stack reads with ETags #22078

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/22078/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 95 additions and 8 deletions.

x
0 of 2 viewed, 2 left
40 additions and 0 deletionspackages/source-control-github/src/server/GitHubPullRequestApi.test.tsModified
View file
@@ -1119,6 +1119,46 @@
+ it.effect("revalidates a polled stack, per credential, so an unchanged one costs no quota", () =>
+ Effect.gen(function* () {
+ const listing = encodeJson([
+ {
+ number: 4,
+ url: "https://api.github.com/repos/acme/poll/stacks/4",
+ base: { ref: "main" },
+ pull_requests: [
+ { number: 9, head: { ref: "feat/nine" }, state: "open", merged_at: null },
+ ],
+ },
+ ]);
+ const read = Effect.flatMap(GitHubPullRequestApi.GitHubPullRequestApi, (cli) =>
+ cli.getPullRequestStack({
+ cwd: "/w",
+ repository: "acme/poll",
+ host: "github.com",
+ number: 9,
+ }),
+ );
+ mockedExecute.mockReturnValueOnce(
+ Effect.succeed(output(listing, false, false, { etag: 'W/"v1"' })),
+ );
+ const first = yield* read;
+ mockedExecute.mockReturnValueOnce(Effect.succeed(output("", false, false, {}, 304)));
+ const second = yield* read;