Skip to content
Myr

import-examples.test.ts

This file

Path

packages/config/test/import-examples.test.ts

744 lines · 24.8 KiB · TypeScript

Last changed by

Merge infra/drop-demo into mainoscabrielbefore adoptionc49b6bf

History of this file

Take it

1import { NodeServices } from "@effect/platform-node";2import { describe, expect, it } from "@effect/vitest";3import { ProjectExists } from "@repo/protocol/refusal";4import {5  Console,6  Data,7  Duration,8  Effect,9  Fiber,10  FileSystem,11  Layer,12  Option,13  Path,14  Redacted,15  Exit,16  Ref,17  Result,18  Schema,19} from "effect";20import { TestClock } from "effect/testing";2122import { LedgerFile, readLedger } from "../../../infra/created.ts";23import {24  examples,25  planImports,26  shownCommand,27  tagBackfillCommands,28  warmPaths,29} from "../../../scripts/lib/import/plan.ts";30import type { ImportExample } from "../../../scripts/lib/import/plan.ts";31import {32  importExamples,33  ImportTarget,34  initUntilAnswered,35  optionsOf,36  TagBackfill,37  Warmer,38} from "../../../scripts/lib/import/run.ts";39import { keyOf, ProjectName } from "../../protocol/src/ids.ts";4041// A project of the plan by the key it was imported under (`anyhow`), read42// as its name (`github.com/dtolnay/anyhow`), as every surface reads it.43const project = (key: string) => Schema.decodeSync(ProjectName)(key);4445const names = (planned: readonly ImportExample[]) =>46  planned.map(({ name }) => name);4748describe("the import plan", () => {49  it("holds the eight repos of the preview first, then thirty well-known ones, each on its branch with its licence", () => {50    expect(51      examples.map(({ branch, key, licence, url }) => [52        key,53        branch,54        url,55        licence,56      ])57    ).toStrictEqual([58      [59        "anyhow",60        "master",61        "https://github.com/dtolnay/anyhow",62        "MIT OR Apache-2.0",63      ],64      ["ky", "main", "https://github.com/sindresorhus/ky", "MIT"],65      ["gum", "main", "https://github.com/charmbracelet/gum", "MIT"],66      ["click", "main", "https://github.com/pallets/click", "BSD-3-Clause"],67      ["awesome", "main", "https://github.com/sindresorhus/awesome", "CC0-1.0"],68      ["changesets", "main", "https://github.com/changesets/changesets", "MIT"],69      ["stb", "master", "https://github.com/nothings/stb", "MIT OR Unlicense"],70      ["fuzzel", "master", "https://codeberg.org/dnkl/fuzzel", "MIT"],71      ["hono", "main", "https://github.com/honojs/hono", "MIT"],72      ["express", "master", "https://github.com/expressjs/express", "MIT"],73      ["fastify", "main", "https://github.com/fastify/fastify", "MIT"],74      ["zustand", "main", "https://github.com/pmndrs/zustand", "MIT"],75      ["immer", "main", "https://github.com/immerjs/immer", "MIT"],76      ["nanoid", "main", "https://github.com/ai/nanoid", "MIT"],77      ["commander", "master", "https://github.com/tj/commander.js", "MIT"],78      ["execa", "main", "https://github.com/sindresorhus/execa", "MIT"],79      ["chalk", "main", "https://github.com/chalk/chalk", "MIT"],80      ["mitt", "main", "https://github.com/developit/mitt", "MIT"],81      ["clsx", "master", "https://github.com/lukeed/clsx", "MIT"],82      [83        "ripgrep",84        "master",85        "https://github.com/BurntSushi/ripgrep",86        "Unlicense OR MIT",87      ],88      [89        "serde",90        "master",91        "https://github.com/serde-rs/serde",92        "MIT OR Apache-2.0",93      ],94      ["axum", "main", "https://github.com/tokio-rs/axum", "MIT"],95      ["fd", "master", "https://github.com/sharkdp/fd", "MIT OR Apache-2.0"],96      [97        "hyperfine",98        "master",99        "https://github.com/sharkdp/hyperfine",100        "MIT OR Apache-2.0",101      ],102      [103        "bubbletea",104        "main",105        "https://github.com/charmbracelet/bubbletea",106        "MIT",107      ],108      ["fzf", "master", "https://github.com/junegunn/fzf", "MIT"],109      ["cobra", "main", "https://github.com/spf13/cobra", "Apache-2.0"],110      ["gin", "master", "https://github.com/gin-gonic/gin", "MIT"],111      ["requests", "main", "https://github.com/psf/requests", "Apache-2.0"],112      ["flask", "main", "https://github.com/pallets/flask", "BSD-3-Clause"],113      ["httpx", "master", "https://github.com/encode/httpx", "BSD-3-Clause"],114      ["typer", "master", "https://github.com/fastapi/typer", "MIT"],115      ["jinja", "main", "https://github.com/pallets/jinja", "BSD-3-Clause"],116      ["lua", "master", "https://github.com/lua/lua", "MIT"],117      ["jq", "master", "https://github.com/jqlang/jq", "MIT"],118      ["kilo", "master", "https://github.com/antirez/kilo", "BSD-2-Clause"],119      ["sinatra", "main", "https://github.com/sinatra/sinatra", "MIT"],120      ["nvm", "master", "https://github.com/nvm-sh/nvm", "MIT"],121    ]);122  });123124  it("names each project at its source path, beside the key it was first imported under", () => {125    expect(126      examples127        .filter(({ key }) => ["click", "commander", "fuzzel"].includes(key))128        .map(({ key, name }) => [key, name])129    ).toStrictEqual([130      ["click", "github.com/pallets/click"],131      ["fuzzel", "codeberg.org/dnkl/fuzzel"],132      ["commander", "github.com/tj/commander"],133    ]);134  });135136  it.effect.each([137    ["github.com/pallets/click"],138    ["click"],139    ["GitHub.com/Pallets/click"],140  ] as const)("takes --only %s as click", ([named]) =>141    Effect.map(optionsOf(["--world", "node", "--only", named]), ({ only }) => {142      expect(only).toStrictEqual(Option.some("github.com/pallets/click"));143    })144  );145146  it("names each project once, as a name the platform takes", () => {147    const all = names(examples);148149    expect(new Set(all).size).toBe(all.length);150    expect(all.filter((name) => !Schema.is(ProjectName)(name))).toStrictEqual(151      []152    );153  });154155  it("skips a project the platform lists already, and keeps only the one --only names", () => {156    expect({157      all: names(158        planImports(159          examples,160          new Set([project("ky"), project("stb")]),161          Option.none()162        )163      ),164      listed: names(165        planImports(166          examples,167          new Set([project("anyhow")]),168          Option.some(project("anyhow"))169        )170      ),171      only: names(172        planImports(examples, new Set(), Option.some(project("gum")))173      ),174    }).toStrictEqual({175      all: names(examples).filter(176        (name) =>177          name !== "github.com/sindresorhus/ky" &&178          name !== "github.com/nothings/stb"179      ),180      listed: [],181      only: ["github.com/charmbracelet/gum"],182    });183  });184});185186describe("the warm plan", () => {187  it("reads a project's home, its tree, its landings, and its README and why the README is there", () => {188    expect(warmPaths(project("ky"), Option.some("readme.md"))).toStrictEqual([189      "/github.com/sindresorhus/ky",190      "/github.com/sindresorhus/ky/tree/main",191      "/github.com/sindresorhus/ky/commits/main",192      "/github.com/sindresorhus/ky/blob/main/readme.md",193      "/github.com/sindresorhus/ky/why/main/readme.md",194    ]);195  });196197  it("reads no README when the project has none", () => {198    expect(warmPaths(project("awesome"), Option.none())).toStrictEqual([199      "/github.com/sindresorhus/awesome",200      "/github.com/sindresorhus/awesome/tree/main",201      "/github.com/sindresorhus/awesome/commits/main",202    ]);203  });204});205206describe("the tag backfill's commands", () => {207  const token = Redacted.make("artifacts-write-token-0123456789abcdef");208209  const commands = tagBackfillCommands({210    mirror: "/tmp/import-tags/anyhow.git",211    remote: {212      token,213      url: "https://acct.artifacts.cloudflare.net/git/projects-dev-oscabriel/anyhow.git",214    },215    source: "https://github.com/dtolnay/anyhow",216  });217218  it("fetches the source's tags into a local bare repo, then pushes refs/tags/* and nothing else", () => {219    expect(commands.map(shownCommand)).toStrictEqual([220      "git init --bare --quiet /tmp/import-tags/anyhow.git",221      "git --git-dir /tmp/import-tags/anyhow.git fetch --quiet --no-tags https://github.com/dtolnay/anyhow refs/tags/*:refs/tags/*",222      "git --git-dir /tmp/import-tags/anyhow.git push --quiet https://acct.artifacts.cloudflare.net/git/projects-dev-oscabriel/anyhow.git refs/tags/*:refs/tags/*",223    ]);224225    const pushes = commands.filter(({ argv }) => argv.includes("push"));226227    expect(228      pushes.map(({ argv }) => argv.filter((arg) => arg.includes(":")))229    ).toStrictEqual([230      [231        "https://acct.artifacts.cloudflare.net/git/projects-dev-oscabriel/anyhow.git",232        "refs/tags/*:refs/tags/*",233      ],234    ]);235    expect(236      pushes.flatMap(({ argv }) =>237        argv.filter((arg) => /--force|--all|--mirror|main|heads/u.test(arg))238      )239    ).toStrictEqual([]);240  });241242  it("never prints the token: it rides in git's env as a header, redacted, not in an argument or a URL", () => {243    const printed = [244      ...commands.map(shownCommand),245      JSON.stringify(commands),246      JSON.stringify(commands.map(({ env }) => env)),247    ].join("\n");248249    expect(printed.includes(Redacted.value(token))).toBeFalsy();250    expect(251      commands.map(({ env = {} }) =>252        Object.entries(env).map(([name, value]) => [253          name,254          Redacted.value(value),255        ])256      )257    ).toStrictEqual([258      [],259      [],260      [261        ["GIT_CONFIG_COUNT", "1"],262        ["GIT_CONFIG_KEY_0", "http.extraHeader"],263        [264          "GIT_CONFIG_VALUE_0",265          "Authorization: Bearer artifacts-write-token-0123456789abcdef",266        ],267      ],268    ]);269  });270});271272const fakePlatform = (listed: readonly string[]) =>273  Effect.gen(function* () {274    const calls = yield* Ref.make<readonly string[]>([]);275    const have = new Set(listed.map(project));276    const note = (call: string) => Ref.update(calls, (all) => [...all, call]);277278    const target = ImportTarget.of({279      counts: (name) =>280        note(`ls-remote ${keyOf(name)}`).pipe(Effect.as({ heads: 2, tags: 0 })),281      initProject: (example) =>282        note(`init ${example.key} ${example.branch}`).pipe(283          Effect.tap(() => Effect.sync(() => have.add(example.name))),284          Effect.as({ landed: "a".repeat(40) })285        ),286      label: "dev-oscabriel (https://platform.test)",287      listProjects: note("listProjects").pipe(288        Effect.andThen(Effect.sync(() => new Set(have)))289      ),290    });291292    const backfill = TagBackfill.of({293      backfill: (example) => note(`tags ${example.key}`).pipe(Effect.as(105)),294    });295296    // Every read answers but fuzzel's why, which the web never answered.297    const warmer = Warmer.of({298      warm: (name) =>299        note(`warm ${keyOf(name)}`).pipe(300          Effect.as(301            warmPaths(name, Option.some("README.md")).map((path) =>302              keyOf(name) === "fuzzel" && path.includes("/why/")303                ? { ok: false, path, said: "no answer" }304                : { ok: true, path, said: "200" }305            )306          )307        ),308    });309310    return {311      calls: Ref.get(calls),312      layer: Layer.mergeAll(313        Layer.succeed(ImportTarget, target),314        Layer.succeed(TagBackfill, backfill),315        Layer.succeed(Warmer, warmer)316      ),317    };318  });319320const ran = (321  argv: readonly string[],322  layer: Layer.Layer<ImportTarget | TagBackfill | Warmer>323) =>324  Effect.gen(function* () {325    const fs = yield* FileSystem.FileSystem;326    const path = yield* Path.Path;327    const dir = yield* fs.makeTempDirectoryScoped({ prefix: "importing-" });328    const ledgerFile = path.join(dir, "created.jsonl");329    const printed: string[] = [];330331    const captured: Console.Console = {332      ...console,333      log: (...args: readonly unknown[]) => {334        printed.push(args.map(String).join(" "));335      },336    };337338    const result = yield* importExamples(argv, () => layer).pipe(339      Effect.provideService(LedgerFile, ledgerFile),340      Effect.provideService(Console.Console, captured),341      Effect.result342    );343344    const ledger = yield* readLedger.pipe(345      Effect.provideService(LedgerFile, ledgerFile)346    );347348    return { ledger, printed, result };349  });350351const onDev = (...flags: readonly string[]) => [352  "--stage",353  "dev-oscabriel",354  "--url",355  "https://platform.test",356  ...flags,357];358359describe("bun scripts/import-examples.ts", () => {360  it.live(361    "takes --stage prod as any declared stage: its dry run plans the import onto prod",362    () =>363      Effect.gen(function* () {364        const platform = yield* fakePlatform(["ky"]);365366        const { ledger, printed, result } = yield* ran(367          ["--stage", "prod", "--dry-run", "--only", "anyhow"],368          platform.layer369        );370371        expect({372          ledger,373          printed,374          result: Result.isSuccess(result),375        }).toStrictEqual({376          ledger: [],377          printed: [378            "import-examples on dev-oscabriel (https://platform.test): 1 to import, 0 listed already",379            "  would import github.com/dtolnay/anyhow from https://github.com/dtolnay/anyhow (master)",380            "dry run: nothing imported, nothing recorded",381          ],382          result: true,383        });384      }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))385  );386387  it.live(388    "imports each project the platform doesn't list, one at a time, with its counts, warms it, and records each in the ledger as a kept import",389    () =>390      Effect.gen(function* () {391        const fresh = ["anyhow", "awesome", "changesets", "fuzzel"];392393        const platform = yield* fakePlatform(394          examples.flatMap(({ key, name }) =>395            fresh.includes(key) ? [] : [name]396          )397        );398399        const { ledger, printed, result } = yield* ran(onDev(), platform.layer);400401        expect({402          calls: yield* platform.calls,403          ledger: ledger.map(({ by, kind, name, namespace, stage }) => ({404            by,405            kind,406            name,407            namespace,408            stage,409          })),410          printed: printed.filter((line) => !line.startsWith("  skip ")),411          result: Result.isSuccess(result),412          skipped: printed.filter((line) => line.startsWith("  skip ")).length,413        }).toStrictEqual({414          calls: [415            "listProjects",416            ...fresh.flatMap((name) => [417              `init ${name} ${name === "anyhow" || name === "fuzzel" ? "master" : "main"}`,418              `ls-remote ${name}`,419              `warm ${name}`,420            ]),421          ],422          ledger: fresh.flatMap((name) => [423            {424              by: "import",425              kind: "project",426              name,427              namespace: undefined,428              stage: "dev-oscabriel",429            },430            {431              by: "import",432              kind: "repo",433              name,434              namespace: "projects-dev-oscabriel",435              stage: "dev-oscabriel",436            },437          ]),438          printed: [439            "import-examples on dev-oscabriel (https://platform.test): 4 to import, 34 listed already",440            "imported github.com/dtolnay/anyhow (Rust crate, master): main at aaaaaaaaaaaa, 2 heads, 0 tags",441            "  warmed github.com/dtolnay/anyhow: 5 of 5 pages read",442            "imported github.com/sindresorhus/awesome (Markdown list, main): main at aaaaaaaaaaaa, 2 heads, 0 tags",443            "  warmed github.com/sindresorhus/awesome: 5 of 5 pages read",444            "imported github.com/changesets/changesets (TypeScript monorepo, main): main at aaaaaaaaaaaa, 2 heads, 0 tags",445            "  warmed github.com/changesets/changesets: 5 of 5 pages read",446            "imported codeberg.org/dnkl/fuzzel (C on Codeberg, master): main at aaaaaaaaaaaa, 2 heads, 0 tags",447            "  warmed codeberg.org/dnkl/fuzzel: 4 of 5 pages read; /codeberg.org/dnkl/fuzzel/why/main/README.md: no answer",448            "imported 4 of 4, each recorded in infra/created.jsonl as a kept import",449          ],450          result: true,451          skipped: 34,452        });453      }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))454  );455456  it.live(457    "--warm warms every example the platform lists already, and imports nothing it lists",458    () =>459      Effect.gen(function* () {460        const platform = yield* fakePlatform(["ky", "gum"]);461462        const { printed } = yield* ran(463          onDev("--only", "ky", "--warm"),464          platform.layer465        );466467        expect({468          calls: yield* platform.calls,469          printed,470        }).toStrictEqual({471          calls: ["listProjects", "warm ky"],472          printed: [473            "import-examples on dev-oscabriel (https://platform.test): 0 to import, 1 listed already",474            "  skip github.com/sindresorhus/ky: listed already",475            "  warmed github.com/sindresorhus/ky: 5 of 5 pages read",476            "imported 0 of 0, each recorded in infra/created.jsonl as a kept import",477          ],478        });479      }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))480  );481482  it.live("--dry-run prints the plan and imports and records nothing", () =>483    Effect.gen(function* () {484      const platform = yield* fakePlatform(["ky"]);485486      const { ledger, printed } = yield* ran(487        onDev("--dry-run", "--only", "anyhow"),488        platform.layer489      );490491      expect({ calls: yield* platform.calls, ledger, printed }).toStrictEqual({492        calls: ["listProjects"],493        ledger: [],494        printed: [495          "import-examples on dev-oscabriel (https://platform.test): 1 to import, 0 listed already",496          "  would import github.com/dtolnay/anyhow from https://github.com/dtolnay/anyhow (master)",497          "dry run: nothing imported, nothing recorded",498        ],499      });500    }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))501  );502503  it.live(504    "--tags backfills an import that came with no tags, and the ledger says so",505    () =>506      Effect.gen(function* () {507        const platform = yield* fakePlatform([]);508509        const { ledger, printed } = yield* ran(510          onDev("--only", "anyhow", "--tags"),511          platform.layer512        );513514        expect({515          calls: yield* platform.calls,516          ledger: ledger.map(({ kind, name, note }) => [kind, name, note]),517          printed: printed.filter((line) => line.includes("tags")),518        }).toStrictEqual({519          calls: [520            "listProjects",521            "init anyhow master",522            "ls-remote anyhow",523            "tags anyhow",524            "warm anyhow",525          ],526          ledger: [527            ["project", "anyhow", undefined],528            ["repo", "anyhow", undefined],529            ["repo", "anyhow", "tags backfilled"],530          ],531          printed: [532            "imported github.com/dtolnay/anyhow (Rust crate, master): main at aaaaaaaaaaaa, 2 heads, 0 tags",533            "  github.com/dtolnay/anyhow: 105 tags backfilled from https://github.com/dtolnay/anyhow",534          ],535        });536      }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))537  );538539  it.live(540    "--tags backfills an earlier import the ledger records, and never a listed project it doesn't",541    () =>542      Effect.gen(function* () {543        const fs = yield* FileSystem.FileSystem;544        const path = yield* Path.Path;545546        const dir = yield* fs.makeTempDirectoryScoped({ prefix: "importing-" });547548        const ledgerFile = path.join(dir, "created.jsonl");549        const platform = yield* fakePlatform(["anyhow", "ky"]);550551        yield* fs.writeFileString(552          ledgerFile,553          `${JSON.stringify({ at: "2026-10-08T20:00:00.000Z", by: "import", kind: "project", name: "anyhow", stage: "dev-oscabriel" })}\n`554        );555556        yield* importExamples(onDev("--tags"), () => platform.layer).pipe(557          Effect.provideService(LedgerFile, ledgerFile),558          Effect.provideService(Console.Console, {559            ...console,560            log: () => {},561          })562        );563564        expect(565          (yield* platform.calls).filter((call) => /ky|anyhow/u.test(call))566        ).toStrictEqual(["ls-remote anyhow", "tags anyhow"]);567      }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))568  );569570  it.live(571    "--sources asks initProject again for each import the ledger records, listed or not, and never for a listed project it doesn't",572    () =>573      Effect.gen(function* () {574        const fs = yield* FileSystem.FileSystem;575        const path = yield* Path.Path;576577        const dir = yield* fs.makeTempDirectoryScoped({ prefix: "importing-" });578579        const ledgerFile = path.join(dir, "created.jsonl");580581        const platform = yield* fakePlatform(["anyhow", "ky"]);582583        yield* fs.writeFileString(584          ledgerFile,585          ["anyhow", "gum"]586            .map(587              (name) =>588                `${JSON.stringify({ at: "2026-10-08T20:00:00.000Z", by: "import", kind: "project", name, stage: "dev-oscabriel" })}\n`589            )590            .join("")591        );592593        const printed: string[] = [];594595        yield* importExamples(596          onDev("--only", "gum", "--sources"),597          () => platform.layer598        ).pipe(599          Effect.provideService(LedgerFile, ledgerFile),600          Effect.provideService(Console.Console, {601            ...console,602            log: (...args: readonly unknown[]) => {603              printed.push(args.map(String).join(" "));604            },605          })606        );607608        yield* importExamples(onDev("--sources"), () => platform.layer).pipe(609          Effect.provideService(LedgerFile, ledgerFile),610          Effect.provideService(Console.Console, {611            ...console,612            log: () => {},613          })614        );615616        expect(617          (yield* platform.calls).filter((call) => /gum|anyhow|ky/u.test(call))618        ).toStrictEqual([619          "init gum main",620          "init anyhow master",621          "init gum main",622        ]);623        expect(printed).toStrictEqual([624          "import-examples on dev-oscabriel (https://platform.test): 0 to import, 1 listed already",625          "  skip github.com/charmbracelet/gum: imported already, as the ledger records",626          "  github.com/charmbracelet/gum: source kept: https://github.com/charmbracelet/gum (main)",627          "imported 0 of 0, each recorded in infra/created.jsonl as a kept import",628        ]);629      }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))630  );631632  it.live(633    "--sources --dry-run prints each source it would keep, and keeps none",634    () =>635      Effect.gen(function* () {636        const platform = yield* fakePlatform(["anyhow"]);637638        const { ledger, printed } = yield* ran(639          onDev("--only", "anyhow", "--sources", "--dry-run"),640          platform.layer641        );642643        expect({644          calls: yield* platform.calls,645          ledger,646          printed: printed.filter((line) => line.includes("source")),647        }).toStrictEqual({648          calls: ["listProjects"],649          ledger: [],650          printed: [],651        });652      }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))653  );654655  it.live(656    "--sources in the Node world goes over every example listed, with no ledger",657    () =>658      Effect.gen(function* () {659        const platform = yield* fakePlatform(["anyhow", "ky"]);660661        const { printed } = yield* ran(662          ["--world", "node", "--sources", "--dry-run"],663          platform.layer664        );665666        expect(printed.filter((line) => line.includes("source"))).toStrictEqual(667          [668            "  would keep the source of github.com/dtolnay/anyhow: https://github.com/dtolnay/anyhow (master)",669            "  would keep the source of github.com/sindresorhus/ky: https://github.com/sindresorhus/ky (main)",670          ]671        );672      }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))673  );674});675676class NoAnswer extends Data.TaggedError("NoAnswer")<{677  readonly after: string;678}> {}679680const askedAgain = (681  answers: readonly Effect.Effect<682    { readonly landed?: string },683    NoAnswer | ProjectExists684  >[]685) =>686  Effect.gen(function* () {687    const made = yield* Ref.make(0);688689    const call = Effect.flatMap(690      Ref.getAndUpdate(made, (count) => count + 1),691      (count) => answers[count] ?? Effect.die("asked once too often")692    );693694    const fiber = yield* Effect.forkChild(695      initUntilAnswered(call, (error) => !(error instanceof NoAnswer))696    );697698    yield* TestClock.adjust(Duration.minutes(2));699700    return { calls: yield* Ref.get(made), ended: yield* Fiber.await(fiber) };701  });702703describe("an import's initProject, asked again", () => {704  const anyhow = project("anyhow");705706  it.effect(707    "takes ProjectExists after a call that got no answer as that call's project, made",708    () =>709      Effect.gen(function* () {710        expect(711          yield* askedAgain([712            Effect.fail(new NoAnswer({ after: "100 s" })),713            Effect.fail(new ProjectExists({ project: anyhow })),714          ])715        ).toStrictEqual({ calls: 2, ended: Exit.succeed({}) });716      })717  );718719  it.effect(720    "answers ProjectExists on the first call, and asks nothing again",721    () =>722      Effect.gen(function* () {723        expect(724          yield* askedAgain([725            Effect.fail(new ProjectExists({ project: anyhow })),726          ])727        ).toStrictEqual({728          calls: 1,729          ended: Exit.fail(new ProjectExists({ project: anyhow })),730        });731      })732  );733734  it.effect("gives up after three more calls with no answer", () =>735    Effect.gen(function* () {736      const lost = Effect.fail(new NoAnswer({ after: "100 s" }));737738      expect(yield* askedAgain([lost, lost, lost, lost])).toStrictEqual({739        calls: 4,740        ended: Exit.fail(new NoAnswer({ after: "100 s" })),741      });742    })743  );744});