Skip to content

Commit 609d6f5

Browse files
authored
Attribute retained repository test journals (#1383) (#1383)
1 parent 21c930a commit 609d6f5

4 files changed

Lines changed: 156 additions & 88 deletions

File tree

‎packages/cli/tests/retained-repository-lifecycle.test.ts‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import { Permissions } from "@executablemd/runtime";
1616
* once the holder has gone.
1717
*/
1818

19-
import { describe, it } from "@executablemd/test-support/bdd";
19+
import { beforeEach, describe, it } from "@executablemd/test-support/bdd";
20+
import { journalBeforeEach, useJournalStream } from "@executablemd/test-support/failure-journal";
2021
import { expect } from "@executablemd/test-support/expect";
2122
import {
2223
type Operation,
@@ -322,6 +323,7 @@ function localRecords(events: readonly DurableEvent[]): number {
322323

323324
/** The question a held entry stands at, never answered. */
324325
const QUESTION = '<Elicit schema={{ type: "object" }} as="answer">Holding</Elicit>';
326+
const OWNER = "packages/cli/tests/retained-repository-lifecycle.test.ts";
325327

326328
/** A question that is answered at once, for a continuation past one. */
327329
function answeringOnce(): () => Operation<unknown> {
@@ -332,11 +334,12 @@ function answeringOnce(): () => Operation<unknown> {
332334
}
333335

334336
describe("the holds an entry takes on the checkout it is working in", () => {
337+
beforeEach(journalBeforeEach(OWNER));
335338
it("E8: lets a second live entry read and change a checkout the first is changing", function* () {
336339
const fixture = yield* useFixture();
337340
const holding = counters();
338341
const second = counters();
339-
const first = new InMemoryStream();
342+
const first = yield* useJournalStream(join(fixture.checkout, "entry.md"));
340343

341344
yield* scoped(function* (): Operation<void> {
342345
// One entry that has already changed the checkout and is standing at a
@@ -373,7 +376,7 @@ describe("the holds an entry takes on the checkout it is working in", () => {
373376
"</Dir>",
374377
'<File path="sentinel.md">sentinel</File>',
375378
].join("\n"),
376-
new InMemoryStream(),
379+
yield* useJournalStream(join(fixture.checkout, "entry.md")),
377380
second,
378381
);
379382

@@ -408,7 +411,7 @@ describe("the holds an entry takes on the checkout it is working in", () => {
408411
const performed = yield* entry(
409412
fixture.checkout,
410413
['<Dir path="made">', '<File path="inside.md">inside</File>', "</Dir>"].join("\n"),
411-
new InMemoryStream(),
414+
yield* useJournalStream(join(fixture.checkout, "entry.md")),
412415
counted,
413416
);
414417

@@ -434,7 +437,7 @@ describe("the holds an entry takes on the checkout it is working in", () => {
434437
'<File.Delete path="one.md" />',
435438
"</Dir>",
436439
].join("\n"),
437-
new InMemoryStream(),
440+
yield* useJournalStream(join(fixture.checkout, "entry.md")),
438441
counted,
439442
);
440443

@@ -513,7 +516,7 @@ describe("the holds an entry takes on the checkout it is working in", () => {
513516
yield* entry(
514517
fixture.checkout,
515518
source,
516-
new InMemoryStream(),
519+
yield* useJournalStream(join(fixture.checkout, "entry.md")),
517520
holding,
518521
function* (): Operation<void> {
519522
acquired.resolve();
@@ -531,7 +534,7 @@ describe("the holds an entry takes on the checkout it is working in", () => {
531534
const second = yield* entry(
532535
fixture.checkout,
533536
source,
534-
new InMemoryStream(),
537+
yield* useJournalStream(join(fixture.checkout, "entry.md")),
535538
blocked,
536539
answeringOnce(),
537540
managed,
@@ -550,7 +553,7 @@ describe("the holds an entry takes on the checkout it is working in", () => {
550553
const later = yield* entry(
551554
fixture.checkout,
552555
source,
553-
new InMemoryStream(),
556+
yield* useJournalStream(join(fixture.checkout, "entry.md")),
554557
after,
555558
answeringOnce(),
556559
managed,
@@ -599,7 +602,7 @@ describe("the holds an entry takes on the checkout it is working in", () => {
599602
yield* entry(
600603
origin,
601604
['<Worktree name="held" branch="held">', QUESTION, "</Worktree>"].join("\n"),
602-
new InMemoryStream(),
605+
yield* useJournalStream(join(origin, "entry.md")),
603606
holding,
604607
function* (): Operation<void> {
605608
acquired.resolve();
@@ -914,7 +917,7 @@ describe("the holds an entry takes on the checkout it is working in", () => {
914917
`<Repository name="project" url=${JSON.stringify(origin)} as="project" />`,
915918
QUESTION,
916919
].join("\n"),
917-
new InMemoryStream(),
920+
yield* useJournalStream(join(fixture.elsewhere, "entry.md")),
918921
holding,
919922
function* (): Operation<void> {
920923
acquired.resolve();
@@ -1001,7 +1004,7 @@ describe("the holds an entry takes on the checkout it is working in", () => {
10011004
QUESTION,
10021005
"</Worktree>",
10031006
].join("\n"),
1004-
new InMemoryStream(),
1007+
yield* useJournalStream(join(origin, "entry.md")),
10051008
holding,
10061009
function* (): Operation<void> {
10071010
acquired.resolve();
@@ -1069,7 +1072,7 @@ function leftEntry(
10691072
root: string,
10701073
): Operation<readonly DurableEvent[]> {
10711074
return scoped(function* () {
1072-
const stream = new InMemoryStream();
1075+
const stream = yield* useJournalStream(join(checkout, "entry.md"));
10731076
const reached = withResolvers<void>();
10741077
const task = yield* spawn(() =>
10751078
entry(

0 commit comments

Comments
 (0)