Skip to content
Myr

memory.test.ts

This file

Path

packages/artifacts/test/memory.test.ts

90 lines · 2.8 KiB · TypeScript

Last changed by

Merge branch 'build/913-import-any-branch-and-examples'oscabrielbefore adoptiona4543f6

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 1–18why, one step back
1import { describe, expect, it } from "@effect/vitest";
2import { gitClient } from "@repo/testkit/git-client";3import { Effect, Option } from "effect";45import {6 BranchName,7 ImportRefused,8 RefName,9 RepoHost,10 RepoName,11 RepoNotFound,12} from "../src/repo-host.ts";13import { memoryFs } from "../src/repo-host/memory-fs.ts";14import { RepoHostMemory } from "../src/repo-host/memory.ts";15import { describeRepoHost } from "./repo-host-contract.ts";1617// Its test-only meaning of a public remote: another repo in the same store.18describeRepoHost("memory", RepoHostMemory, {

Merge branch 'build/913-import-any-branch-and-examples'oscabrielbefore adoptiona4543f6

line 19why, one step back
19 danglingHead: true,

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 20–90why, one step back
20 importUrl: (name) =>
21 RepoHost.use((repos) => repos.remote(name)).pipe(Effect.orDie),22});2324describe("importing into the memory store", () => {25 it.effect("imports the branch it names, under that name", () =>26 Effect.gen(function* () {27 const repos = yield* RepoHost;28 const client = yield* gitClient(memoryFs());29 const first = yield* client.commit("first", [["a", "1"]]);30 const remote = RepoName.make("branches");31 const name = RepoName.make("from-a-branch");3233 yield* repos.create(remote);34 yield* repos.push(remote, client.source, [35 {36 from: Option.none(),37 ref: RefName.make("refs/heads/release"),38 to: first,39 },40 ]);4142 yield* repos.importFrom(name, {43 branch: BranchName.make("release"),44 url: yield* repos.remote(remote),45 });4647 expect(yield* repos.refs(name)).toStrictEqual(48 new Map([[RefName.make("refs/heads/release"), first]])49 );50 }).pipe(Effect.provide(RepoHostMemory))51 );5253 it.effect("refuses a remote that is no repo in the store", () =>54 Effect.gen(function* () {55 const repos = yield* RepoHost;56 const name = RepoName.make("nowhere");5758 expect(59 yield* Effect.flip(60 repos.importFrom(name, { url: "https://example.com/demo.git" })61 )62 ).toStrictEqual(63 new ImportRefused({64 name,65 reason: "no repo at https://example.com/demo.git",66 })67 );68 expect(yield* Effect.flip(repos.refs(name))).toStrictEqual(69 new RepoNotFound({ name })70 );71 }).pipe(Effect.provide(RepoHostMemory))72 );7374 it.effect("refuses a branch the remote lacks, and makes no repo", () =>75 Effect.gen(function* () {76 const repos = yield* RepoHost;77 const remote = RepoName.make("empty-remote");78 const name = RepoName.make("from-nothing");7980 yield* repos.create(remote);8182 const url = yield* repos.remote(remote);8384 expect(yield* Effect.flip(repos.importFrom(name, { url }))).toStrictEqual(85 new ImportRefused({ name, reason: `${url} has no branch main` })86 );87 expect(yield* repos.remove(name)).toBeFalsy();88 }).pipe(Effect.provide(RepoHostMemory))89 );90});