Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AzureDevOpsPullRequestProvider.test.ts

640 lines23.0 KB

1import { describe, expect, it } from "@effect/vitest";
2import * as Deferred from "effect/Deferred";
3import * as Effect from "effect/Effect";
4import * as Fiber from "effect/Fiber";
5import * as Layer from "effect/Layer";
6import type { PullRequestCheck, PullRequestCheckStatus } from "@t3tools/contracts";
7​
8import * as AzureDevOpsPullRequestCli from "./AzureDevOpsPullRequestCli.ts";
9import {
10 BLOB_BATCH_FILES,
11 LOCATION_CACHE_CAPACITY,
12 make,
13 MAX_DIFF_SPAWNS,
14} from "./AzureDevOpsPullRequestProvider.ts";
15import {
16 byteLength,
17 MAX_DIFF_SLICE_BYTES,
18 MAX_DIFF_SLICE_FILES,
19 MAX_FILE_DIFF_EDITS,
20 parseAzureDevOpsDiffCursor,
21} from "./azureDevOpsDiff.ts";
22import type { AzureDevOpsChangeEntry } from "./azureDevOpsPullRequestJson.ts";
23​
24const ITERATION = { id: 3, headCommit: "head", mergeBaseCommit: "base" };
25​
26const PULL_REQUEST = {
27 number: 7,
28 title: "Pull request 7",
29 url: "https://dev.azure.com/acme/web/_git/web/pullrequest/7",
30 author: null,
31 headBranch: "feat/page",
32 baseBranch: "main",
33 state: "open" as const,
34 isDraft: false,
35 mergeability: "mergeable" as const,
36 createdAt: "2026-07-01T00:00:00Z",
37 updatedAt: "2026-07-02T00:00:00Z",
38 closedAt: null,
39 body: "",
40 reviewRequestLogins: [],
41 reviewers: [],
42 location: { project: "acme", repository: "web" },
43 autoMergeEnabled: false,
44};
45​
46function change(
47 path: string,
48 changeKind: AzureDevOpsChangeEntry["changeKind"] = "change",
49): AzureDevOpsChangeEntry {
50 return { path, oldPath: path, changeKind, objectId: "8f80", originalObjectId: "0ca4" };
52​
53/** A batch that returns nothing, so every file takes the per-file read. */
54const NO_BLOBS = { readBlobs: () => Effect.succeed(new Map()) };
55​
56function side(prefix: string, lines: number, width: number): string {
57 const pad = "z".repeat(width);
58 return `${Array.from({ length: lines }, (_, line) => `${prefix} ${line} ${pad}`).join("\n")}\n`;
60​
61const readSlice = (input: {
62 readonly paths: ReadonlyArray<string>;
63 readonly lines: number;
64 readonly width: number;
65 readonly refused?: ReadonlyArray<string>;
66 readonly created?: ReadonlyArray<string>;
67 readonly cursor?: string;
68}) =>
69 Effect.gen(function* () {
70 const reads: string[] = [];
71 const refused = new Set(input.refused ?? []);
72 const created = new Set(input.created ?? []);
73 let inFlight = 0;
74 let peakInFlight = 0;
75​
76 const provider = yield* make.pipe(
77 Effect.provide(
78 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
79 ...NO_BLOBS,
80 getPullRequest: () => Effect.succeed(PULL_REQUEST),
81 listIterations: () => Effect.succeed([ITERATION]),
82 listIterationChanges: () =>
83 Effect.succeed({
84 changes: input.paths.map((path) =>
85 change(path, created.has(path) ? "new" : "change"),
86 ),
87 truncated: false,
88 }),
89 readItemContent: (item) =>
90 Effect.gen(function* () {
91 reads.push(item.path);
92 inFlight += 1;
93 peakInFlight = Math.max(peakInFlight, inFlight);
94 // Yield like a subprocess to exercise concurrency.
95 const answersAfter = input.paths.length - input.paths.indexOf(item.path);
96 for (let turn = 0; turn < answersAfter; turn += 1) yield* Effect.yieldNow;
97 inFlight -= 1;
98 if (refused.has(item.path)) {
99 return yield* new AzureDevOpsPullRequestCli.AzureDevOpsPullRequestReadError({
100 command: "az",
101 cwd: "/w",
102 operation: "readItemContent",
103 cause: "refused",
104 });
105 }
106 const isOldSide = item.commit !== ITERATION.headCommit;
107 if (isOldSide && created.has(item.path)) return { contents: "", isBinary: false };
108 return {
109 contents: side(isOldSide ? "old" : "new", input.lines, input.width),
110 isBinary: false,
111 };
112 }),
113 }),
114 ),
115 );
116​
117 const slice = yield* provider.getDiff({
118 cwd: "/w",
119 repository: "acme/web",
120 host: "dev.azure.com",
121 number: 7,
122 ...(input.cursor === undefined ? {} : { cursor: input.cursor }),
123 });
124 return { slice, reads, peakInFlight };
125 });
126​
127function patchedPaths(patch: string): ReadonlyArray<string> {
128 return [...patch.matchAll(/^diff --git a\/(?<path>\S+) b\//gmu)].map(
129 (match) => match.groups?.path ?? "",
130 );
132​
133describe("getChangeRequest", () => {
134 it.effect("preserves the newest head when file counting fails", () =>
135 Effect.gen(function* () {
136 const provider = yield* make.pipe(
137 Effect.provide(
138 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
139 getPullRequest: () => Effect.succeed(PULL_REQUEST),
140 listPolicyChecks: () => Effect.succeed([]),
141 listIterations: () =>
142 Effect.succeed([ITERATION, { ...ITERATION, id: 4, headCommit: "new-head" }]),
143 listIterationChanges: () =>
144 Effect.fail(
145 new AzureDevOpsPullRequestCli.AzureDevOpsPullRequestReadError({
146 command: "az",
147 cwd: "/w",
148 operation: "listIterationChanges",
149 cause: "unavailable",
150 }),
151 ),
152 }),
153 ),
154 );
155​
156 const detail = yield* provider.getChangeRequest({
157 cwd: "/w",
158 repository: "acme/web",
159 host: "dev.azure.com",
160 number: 7,
161 });
162 expect(detail.headSha).toBe("new-head");
163 expect(detail.changedFiles).toBe(0);
164 }),
165 );
166​
167 it.effect.each(["missing", "failed"] as const)(
168 "leaves the head unavailable when the iteration read is %s",
169 (state) =>
170 Effect.gen(function* () {
171 const provider = yield* make.pipe(
172 Effect.provide(
173 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
174 getPullRequest: () => Effect.succeed(PULL_REQUEST),
175 listPolicyChecks: () => Effect.succeed([]),
176 listIterations: () =>
177 state === "missing"
178 ? Effect.succeed([])
179 : Effect.fail(
180 new AzureDevOpsPullRequestCli.AzureDevOpsPullRequestReadError({
181 command: "az",
182 cwd: "/w",
183 operation: "listIterations",
184 cause: "unavailable",
185 }),
186 ),
187 }),
188 ),
189 );
190 const detail = yield* provider.getChangeRequest({
191 cwd: "/w",
192 repository: "acme/web",
193 host: "dev.azure.com",
194 number: 7,
195 });
196 expect(detail.headSha).toBeUndefined();
197 expect(detail.changedFiles).toBe(0);
198 }),
199 );
200​
201 it.effect(
202 "reads the pull request once for overlapping detail and conversation, then its diff",
203 () =>
204 Effect.gen(function* () {
205 let reads = 0;
206 const release = yield* Deferred.make<void>();
207 const provider = yield* make.pipe(
208 Effect.provide(
209 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
210 getPullRequest: () =>
211 Effect.sync(() => {
212 reads += 1;
213 }).pipe(Effect.andThen(Deferred.await(release)), Effect.as(PULL_REQUEST)),
214 listIterations: () => Effect.succeed([ITERATION]),
215 listIterationChanges: () =>
216 Effect.succeed({ changes: [change("a.ts")], truncated: false }),
217 readItemContent: () =>
218 Effect.succeed({ contents: side("new", 2, 4), isBinary: false }),
219 ...NO_BLOBS,
220 listPolicyChecks: () => Effect.succeed([]),
221 listThreads: () => Effect.succeed([]),
222 }),
223 ),
224 );
225 const input = { cwd: "/w", repository: "acme/web", host: "dev.azure.com", number: 7 };
226​
227 // Clients request detail and conversation together; both start before the read returns.
228 const detail = yield* Effect.forkChild(provider.getChangeRequest(input), {
229 startImmediately: true,
230 });
231 const activity = yield* Effect.forkChild(provider.getChangeRequestActivity(input), {
232 startImmediately: true,
233 });
234 yield* Deferred.succeed(release, undefined);
235 yield* Fiber.join(detail);
236 yield* Fiber.join(activity);
237 yield* provider.getDiff(input);
238​
239 expect(reads).toBe(1);
240 }),
241 );
242});
243​
244describe("policy checks", () => {
245 const REPOSITORY = {
246 cwd: "/w",
247 repository: "acme/web",
248 host: "dev.azure.com",
249 number: 7,
250 };
251 const check = (status: PullRequestCheckStatus): PullRequestCheck => ({
252 name: "PR validation",
253 status,
254 description: null,
255 url: null,
256 required: true,
257 });
258 const readFailure = new AzureDevOpsPullRequestCli.AzureDevOpsPullRequestReadError({
259 command: "az",
260 cwd: "/w",
261 operation: "listPolicyChecks",
262 cause: "unavailable",
263 });
264​
265 const provide = (
266 listPolicyChecks: AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli["Service"]["listPolicyChecks"],
267 pullRequest = PULL_REQUEST,
268 ) =>
269 make.pipe(
270 Effect.provide(
271 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
272 getPullRequest: () => Effect.succeed(pullRequest),
273 listIterations: () => Effect.succeed([ITERATION]),
274 listIterationChanges: () => Effect.succeed({ changes: [], truncated: false }),
275 listPolicyChecks,
276 }),
277 ),
278 );
279​
280 it.effect("keeps the detail readable when the policies are not", () =>
281 Effect.gen(function* () {
282 const provider = yield* provide(() => Effect.fail(readFailure));
283 const detail = yield* provider.getChangeRequest(REPOSITORY);
284 expect(detail.checks).toEqual([]);
285 }),
286 );
287​
288 it.effect.each([
289 { statuses: ["pending", "failure"], expected: "failing" },
290 { statuses: [], expected: null },
291 ] as const)("summarizes $statuses as $expected", ({ statuses, expected }) =>
292 Effect.gen(function* () {
293 const provider = yield* provide(() => Effect.succeed(statuses.map(check)));
294 const summary = yield* provider.getChangeRequestSummary!(REPOSITORY);
295 expect(summary.checksState).toBe(expected);
296 }),
297 );
298​
299 it.effect("leaves the last known state alone when the policies cannot be read", () =>
300 Effect.gen(function* () {
301 const provider = yield* provide(() => Effect.fail(readFailure));
302 const summary = yield* provider.getChangeRequestSummary!(REPOSITORY);
303 expect(summary.checksState).toBeUndefined();
304 }),
305 );
306});
307​
308describe("getDiff reads", () => {
309 it.effect("holds every reader together to one request's worth of processes", () =>
310 Effect.gen(function* () {
311 const paths = ["a.ts", "b.ts", "c.ts", "d.ts", "e.ts", "f.ts"];
312 let inFlight = 0;
313 let peakInFlight = 0;
314​
315 const provider = yield* make.pipe(
316 Effect.provide(
317 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
318 ...NO_BLOBS,
319 getPullRequest: () => Effect.succeed(PULL_REQUEST),
320 listIterations: () => Effect.succeed([ITERATION]),
321 listIterationChanges: () =>
322 Effect.succeed({ changes: paths.map((path) => change(path)), truncated: false }),
323 readItemContent: () =>
324 Effect.gen(function* () {
325 inFlight += 1;
326 peakInFlight = Math.max(peakInFlight, inFlight);
327 // Yield like a subprocess to exercise concurrency.
328 yield* Effect.yieldNow;
329 yield* Effect.yieldNow;
330 inFlight -= 1;
331 return { contents: side("new", 2, 4), isBinary: false };
332 }),
333 }),
334 ),
335 );
336​
337 const readDiff = (number: number) =>
338 provider.getDiff({ cwd: "/w", repository: "acme/web", host: "dev.azure.com", number });
339​
340 yield* Effect.all([readDiff(7), readDiff(8)], { concurrency: 2 });
341​
342 expect(peakInFlight).toBeLessThanOrEqual(MAX_DIFF_SPAWNS);
343 }),
344 );
345​
346 it.effect("reads a slice's files in one blob batch, and per file only what it missed", () =>
347 Effect.gen(function* () {
348 const paths = ["a.ts", "b.ts", "c.ts", "gone.ts", "added.ts"];
349 const changes = [
350 ...["a.ts", "b.ts", "c.ts"].map((path) => ({
351 ...change(path),
352 objectId: `${path.toUpperCase()}-NEW`,
353 originalObjectId: `${path.toUpperCase()}-OLD`,
354 })),
355 { ...change("gone.ts", "deleted"), objectId: null, originalObjectId: "GONE-OLD" },
356 { ...change("added.ts", "new"), objectId: "ADDED-NEW", originalObjectId: null },
357 ];
358 const batches: ReadonlyArray<string>[] = [];
359 const reads: string[] = [];
360​
361 const provider = yield* make.pipe(
362 Effect.provide(
363 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
364 getPullRequest: () => Effect.succeed(PULL_REQUEST),
365 listIterations: () => Effect.succeed([ITERATION]),
366 listIterationChanges: () => Effect.succeed({ changes, truncated: false }),
367 readBlobs: (input) =>
368 Effect.sync(() => {
369 batches.push(input.objectIds);
370 // Azure left one side of b.ts out, as it does for a file only it can decode.
371 return new Map(
372 input.objectIds
373 .filter((id) => id !== "B.TS-OLD")
374 .map((id) => [
375 id.toLowerCase(),
376 {
377 contents: side(id.endsWith("NEW") ? "new" : "old", 2, 4),
378 isBinary: false,
379 },
380 ]),
381 );
382 }),
383 readItemContent: (item) =>
384 Effect.sync(() => {
385 reads.push(`${item.commit}:${item.path}`);
386 return {
387 contents: side(item.commit === ITERATION.headCommit ? "new" : "old", 2, 4),
388 isBinary: false,
389 };
390 }),
391 }),
392 ),
393 );
394​
395 const slice = yield* provider.getDiff({
396 cwd: "/w",
397 repository: "acme/web",
398 host: "dev.azure.com",
399 number: 7,
400 });
401​
402 expect(patchedPaths(slice.patch)).toEqual(paths);
403 expect(slice.patch.match(/^@@ /gmu)).toHaveLength(paths.length);
404 expect(batches).toEqual([
405 [
406 "A.TS-OLD",
407 "A.TS-NEW",
408 "B.TS-OLD",
409 "B.TS-NEW",
410 "C.TS-OLD",
411 "C.TS-NEW",
412 "GONE-OLD",
413 "ADDED-NEW",
414 ],
415 ]);
416 expect(reads.toSorted()).toEqual(["base:b.ts", "head:b.ts"]);
417 }),
418 );
419​
420 it.effect("starts a new blob batch where the last one's files run out", () =>
421 Effect.gen(function* () {
422 const paths = Array.from({ length: BLOB_BATCH_FILES + 3 }, (_, at) => `f${at}.ts`);
423 // Added lines that bring the slice near its edit budget by file 96, so the read batches
424 // there narrow to 3 and the one from file 99 would reach past the blob batch.
425 const added = (at: number) => (at < 60 ? 41 : at < 96 ? 40 : at < 99 ? 0 : 10);
426 const batchSizes: number[] = [];
427 let fileReads = 0;
428​
429 const provider = yield* make.pipe(
430 Effect.provide(
431 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
432 getPullRequest: () => Effect.succeed(PULL_REQUEST),
433 listIterations: () => Effect.succeed([ITERATION]),
434 listIterationChanges: () =>
435 Effect.succeed({
436 changes: paths.map((path) => ({
437 ...change(path),
438 objectId: `${path}-new`,
439 originalObjectId: `${path}-old`,
440 })),
441 truncated: false,
442 }),
443 readBlobs: (input) =>
444 Effect.sync(() => {
445 batchSizes.push(input.objectIds.length);
446 return new Map(
447 input.objectIds.map((id) => {
448 const at = Number(id.slice(1, id.indexOf(".")));
449 const lines = id.endsWith("-new") ? added(at) : 0;
450 return [
451 id,
452 { contents: lines === 0 ? "" : side("+", lines, 1), isBinary: false },
453 ];
454 }),
455 );
456 }),
457 readItemContent: () =>
458 Effect.sync(() => ((fileReads += 1), { contents: "", isBinary: false })),
459 }),
460 ),
461 );
462​
463 const slice = yield* provider.getDiff({
464 cwd: "/w",
465 repository: "acme/web",
466 host: "dev.azure.com",
467 number: 7,
468 });
469​
470 expect(patchedPaths(slice.patch)).toHaveLength(paths.length);
471 expect(batchSizes).toEqual([2 * BLOB_BATCH_FILES, 6]);
472 expect(fileReads).toBe(0);
473 }),
474 );
475​
476 it.effect("serves a later slice from the iteration and change list the first one read", () =>
477 Effect.gen(function* () {
478 const paths = ["a.ts", "b.ts", "c.ts", "d.ts", "e.ts", "f.ts"];
479 let iterationReads = 0;
480 let changeReads = 0;
481​
482 const provider = yield* make.pipe(
483 Effect.provide(
484 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
485 ...NO_BLOBS,
486 getPullRequest: () => Effect.succeed(PULL_REQUEST),
487 listIterations: () => Effect.sync(() => ((iterationReads += 1), [ITERATION])),
488 listIterationChanges: () =>
489 Effect.sync(() => {
490 changeReads += 1;
491 return { changes: paths.map((path) => change(path)), truncated: false };
492 }),
493 readItemContent: (item) =>
494 Effect.succeed({
495 contents: side(item.commit === ITERATION.headCommit ? "new" : "old", 100, 900),
496 isBinary: false,
497 }),
498 }),
499 ),
500 );
501 const readDiff = (cursor?: string) =>
502 provider.getDiff({
503 cwd: "/w",
504 repository: "acme/web",
505 host: "dev.azure.com",
506 number: 7,
507 ...(cursor === undefined ? {} : { cursor }),
508 });
509​
510 const first = yield* readDiff();
511 const second = yield* readDiff(first.nextCursor ?? undefined);
512​
513 expect(patchedPaths(second.patch)).toEqual(["c.ts", "d.ts"]);
514 expect(iterationReads).toBe(1);
515 expect(changeReads).toBe(1);
516 }),
517 );
518​
519 it.effect("leaves a run of files it could not diff at all for the next slice", () =>
520 Effect.gen(function* () {
521 const paths = Array.from({ length: MAX_DIFF_SLICE_FILES + 20 }, (_, at) => `gen/a${at}.bin`);
522 const read = yield* readSlice({ paths, lines: 2, width: 4, refused: paths });
523​
524 expect(patchedPaths(read.slice.patch)).toHaveLength(MAX_DIFF_SLICE_FILES);
525 expect(byteLength(read.slice.patch)).toBeLessThan(MAX_DIFF_SLICE_BYTES);
526 expect(parseAzureDevOpsDiffCursor(read.slice.nextCursor)?.fileIndex).toBe(
527 MAX_DIFF_SLICE_FILES,
528 );
529 }),
530 );
531​
532 it.effect("keeps the patch in the order the change was listed, whoever answered first", () =>
533 Effect.gen(function* () {
534 const paths = ["a.ts", "b.ts", "c.ts", "d.ts", "e.ts"];
535 const read = yield* readSlice({ paths, lines: 2, width: 4 });
536​
537 expect(patchedPaths(read.slice.patch)).toEqual(paths);
538 expect(read.slice.nextCursor).toBeNull();
539 }),
540 );
541​
542 it.effect("leaves a file the host refused listed without its hunks, in its place", () =>
543 Effect.gen(function* () {
544 const paths = ["a.ts", "b.ts", "c.ts"];
545 const read = yield* readSlice({ paths, lines: 2, width: 4, refused: ["b.ts"] });
546​
547 expect(patchedPaths(read.slice.patch)).toEqual(paths);
548 expect(read.slice.truncated).toBe(true);
549 expect(read.slice.patch).toContain("+++ b/b.ts\ndiff --git a/c.ts");
550 expect(read.slice.patch.match(/^@@ /gmu)).toHaveLength(2);
551 }),
552 );
553});
554​
555describe("what one diff slice spends", () => {
556 it.effect("stops on the byte ceiling without carrying what it read past it", () =>
557 Effect.gen(function* () {
558 const paths = ["a.ts", "b.ts", "c.ts", "d.ts", "e.ts", "f.ts"];
559 const read = yield* readSlice({ paths, lines: 100, width: 900 });
560​
561 expect(read.slice.patch.length).toBeGreaterThan(MAX_DIFF_SLICE_BYTES);
562 expect(patchedPaths(read.slice.patch)).toEqual(["a.ts", "b.ts"]);
563 expect(read.slice.nextCursor).toBe(`${ITERATION.id}:2`);
564 expect(new Set(read.reads)).toEqual(new Set(["a.ts", "b.ts", "c.ts", "d.ts"]));
565 }),
566 );
567​
568 it.effect("stops once the diff work one request may do is spent", () =>
569 Effect.gen(function* () {
570 const paths = Array.from({ length: 12 }, (_, file) => `file-${file}.ts`);
571 const read = yield* readSlice({ paths, lines: MAX_FILE_DIFF_EDITS / 4, width: 1 });
572​
573 expect(read.slice.patch.length).toBeLessThan(MAX_DIFF_SLICE_BYTES);
574 expect(patchedPaths(read.slice.patch)).toEqual(paths.slice(0, 5));
575 expect(read.slice.nextCursor).toBe(`${ITERATION.id}:5`);
576 }),
577 );
578​
579 it.effect("carries a whole new file and stops the slice on what it weighed", () =>
580 Effect.gen(function* () {
581 const paths = ["new.ts", "b.ts", "c.ts", "d.ts"];
582 const read = yield* readSlice({ paths, lines: 8_000, width: 30, created: ["new.ts"] });
583​
584 expect(patchedPaths(read.slice.patch)).toEqual(["new.ts"]);
585 expect(read.slice.patch).toContain("--- /dev/null");
586 expect(read.slice.patch).toContain("@@ -0,0 +1,8000 @@");
587 expect(read.slice.patch.length).toBeGreaterThan(MAX_DIFF_SLICE_BYTES);
588 expect(read.slice.nextCursor).toBe(`${ITERATION.id}:1`);
589 }),
590 );
591​
592 it.effect("carries on from where the last slice stopped", () =>
593 Effect.gen(function* () {
594 const paths = ["a.ts", "b.ts", "c.ts", "d.ts", "e.ts", "f.ts"];
595 const read = yield* readSlice({
596 paths,
597 lines: 100,
598 width: 900,
599 cursor: `${ITERATION.id}:2`,
600 });
601​
602 expect(patchedPaths(read.slice.patch)).toEqual(["c.ts", "d.ts"]);
603 expect(read.slice.nextCursor).toBe(`${ITERATION.id}:4`);
604 }),
605 );
606 it.effect("keeps the pull request being read, not the one looked up first", () =>
607 Effect.gen(function* () {
608 const HOT = 7;
609 const readsOf = new Map<number, number>();
610​
611 const provider = yield* make.pipe(
612 Effect.provide(
613 Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({
614 ...NO_BLOBS,
615 getPullRequest: (input) =>
616 Effect.sync(() => {
617 readsOf.set(input.number, (readsOf.get(input.number) ?? 0) + 1);
618 return { ...PULL_REQUEST, number: input.number };
619 }),
620 listIterations: () => Effect.succeed([ITERATION]),
621 listIterationChanges: () =>
622 Effect.succeed({ changes: [change("a.ts")], truncated: false }),
623 readItemContent: () => Effect.succeed({ contents: side("new", 2, 4), isBinary: false }),
624 }),
625 ),
626 );
627​
628 const readDiff = (number: number) =>
629 provider.getDiff({ cwd: "/w", repository: "acme/web", host: "dev.azure.com", number });
630​
631 yield* readDiff(HOT);
632 for (let filled = 0; filled < LOCATION_CACHE_CAPACITY; filled += 1) {
633 yield* readDiff(HOT + 1 + filled);
634 yield* readDiff(HOT);
635 }
636​
637 expect(readsOf.get(HOT)).toBe(1);
638 }),
639 );
640});