live.test.ts
This file
Path
apps/platform/test/visibility/live.test.ts
66 lines · 2.4 KiB · TypeScript
Last changed by
Merge build/comments-platform into mainoscabrielbefore adoptionddf09e8
History of this fileTake it
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667import { describe, expect, it } from "@effect/vitest";import { Fetch } from "@repo/artifacts/fetch";import { RepoHost } from "@repo/artifacts/repo-host";import { RepoHostMemory } from "@repo/artifacts/repo-host/memory";import { RepoName } from "@repo/protocol/ids";import { fakeArtifactsBinding } from "@repo/testkit/fake-artifacts-binding";import { untouchable } from "@repo/testkit/untouchable";import { LayerRepos } from "@repo/visibility/layer-repos";import { Effect, Exit, Layer } from "effect";
import { decodeEnv } from "../../src/platform.ts";import { workerPorts } from "../../src/ports.ts";import { layerRepos } from "../../src/visibility/layer-repos.ts";import { fakeEnv } from "../fake-env.ts";
const remoteBase = "https://artifacts.test";
const freshHost = Effect.provide(Effect.service(RepoHost), RepoHostMemory);
const noFetch = Layer.succeed(Fetch, untouchable<Fetch["Service"]>("Fetch"));
describe("the visibility cartridge, plugged in", () => { it.effect( "builds over the stage's ports from the decoded env, touching no binding", () => Effect.gen(function* () { const config = yield* decodeEnv(fakeEnv()).pipe(Effect.orDie);
const built = yield* Effect.exit( Effect.scoped(Layer.build(workerPorts(config))) );
expect(Exit.isSuccess(built)).toBeTruthy(); }) );
it.effect( "reaches the layer repos through ARTIFACTS_PRIVATE, never the public namespace", () => Effect.gen(function* () { const publicHost = yield* freshHost; const privateHost = yield* freshHost; const layer = RepoName.make("alice__datekit--maintainers");
yield* privateHost.create(layer);
const config = yield* decodeEnv({ ...fakeEnv(), ARTIFACTS: fakeArtifactsBinding(publicHost, { remoteBase }), ARTIFACTS_PRIVATE: fakeArtifactsBinding(privateHost, { remoteBase }), }).pipe(Effect.orDie);
yield* publicHost.create(RepoName.make("alice__datekit"));
const found = yield* LayerRepos.use((repos) => Effect.all({ layer: Effect.exit(repos.remote(layer)), public: Effect.exit(repos.remote(RepoName.make("alice__datekit"))), }) ).pipe(Effect.provide(layerRepos(config).pipe(Layer.provide(noFetch))));
expect(Exit.isSuccess(found.layer)).toBeTruthy(); expect(Exit.isFailure(found.public)).toBeTruthy(); }) );});