Showing the changes to apps/server/src/workspace/Layers/WorkspaceFileSystem.test.ts (1 of 19 files). Show all
Unified · Split
| @@ -8,20 +8,19 @@ import * as Path from "effect/Path"; · 7 unmodified lines | |||
| 8 | import { ServerConfig } from "../../config.ts"; | 8 | import { ServerConfig } from "../../config.ts"; |
| 9 | import * as VcsDriverRegistry from "../../vcs/VcsDriverRegistry.ts"; | 9 | import * as VcsDriverRegistry from "../../vcs/VcsDriverRegistry.ts"; |
| 10 | import * as VcsProcess from "../../vcs/VcsProcess.ts"; | 10 | import * as VcsProcess from "../../vcs/VcsProcess.ts"; |
| 11 | import { WorkspaceEntries } from "../Services/WorkspaceEntries.ts"; | 11 | import * as WorkspaceEntries from "../WorkspaceEntries.ts"; |
| 12 | import { WorkspaceFileSystem } from "../Services/WorkspaceFileSystem.ts"; | 12 | import { WorkspaceFileSystem } from "../Services/WorkspaceFileSystem.ts"; |
| 13 | import { WorkspaceEntriesLive } from "./WorkspaceEntries.ts"; | ||
| 14 | import { WorkspaceFileSystemLive } from "./WorkspaceFileSystem.ts"; | 13 | import { WorkspaceFileSystemLive } from "./WorkspaceFileSystem.ts"; |
| 15 | import { WorkspacePathsLive } from "./WorkspacePaths.ts"; | 14 | import { WorkspacePathsLive } from "./WorkspacePaths.ts"; |
| 16 | 15 | ||
| 17 | const ProjectLayer = WorkspaceFileSystemLive.pipe( | 16 | const ProjectLayer = WorkspaceFileSystemLive.pipe( |
| 18 | Layer.provide(WorkspacePathsLive), | 17 | Layer.provide(WorkspacePathsLive), |
| 19 | Layer.provide(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))), | 18 | Layer.provide(WorkspaceEntries.layer.pipe(Layer.provide(WorkspacePathsLive))), |
| 20 | ); | 19 | ); |
| 21 | 20 | ||
| 22 | const TestLayer = Layer.empty.pipe( | 21 | const TestLayer = Layer.empty.pipe( |
| 23 | Layer.provideMerge(ProjectLayer), | 22 | Layer.provideMerge(ProjectLayer), |
| 24 | Layer.provideMerge(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))), | 23 | Layer.provideMerge(WorkspaceEntries.layer.pipe(Layer.provide(WorkspacePathsLive))), |
| 25 | Layer.provideMerge(WorkspacePathsLive), | 24 | Layer.provideMerge(WorkspacePathsLive), |
| 26 | Layer.provideMerge(VcsDriverRegistry.layer.pipe(Layer.provide(VcsProcess.layer))), | 25 | Layer.provideMerge(VcsDriverRegistry.layer.pipe(Layer.provide(VcsProcess.layer))), |
| 27 | Layer.provide( | 26 | Layer.provide( |
| @@ -53,7 +52,7 @@ const writeTextFile = Effect.fn("writeTextFile")(function* ( · 25 unmodified lines | |||
| 53 | yield* fileSystem.writeFileString(absolutePath, contents).pipe(Effect.orDie); | 52 | yield* fileSystem.writeFileString(absolutePath, contents).pipe(Effect.orDie); |
| 54 | }); | 53 | }); |
| 55 | 54 | ||
| 56 | it.layer(TestLayer)("WorkspaceFileSystemLive", (it) => { | 55 | it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (it) => { |
| 57 | describe("readFile", () => { | 56 | describe("readFile", () => { |
| 58 | it.effect("reads UTF-8 files relative to the workspace root", () => | 57 | it.effect("reads UTF-8 files relative to the workspace root", () => |
| 59 | Effect.gen(function* () { | 58 | Effect.gen(function* () { |
| @@ -135,20 +134,15 @@ it.layer(TestLayer)("WorkspaceFileSystemLive", (it) => { · 75 unmodified lines | |||
| 135 | 134 | ||
| 136 | it.effect("invalidates workspace entry search cache after writes", () => | 135 | it.effect("invalidates workspace entry search cache after writes", () => |
| 137 | Effect.gen(function* () { | 136 | Effect.gen(function* () { |
| 138 | const workspaceEntries = yield* WorkspaceEntries; | 137 | const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries; |
| 139 | const workspaceFileSystem = yield* WorkspaceFileSystem; | 138 | const workspaceFileSystem = yield* WorkspaceFileSystem; |
| 140 | const cwd = yield* makeTempDir; | 139 | const cwd = yield* makeTempDir; |
| 141 | yield* writeTextFile(cwd, "src/existing.ts", "export {};\n"); | 140 | yield* writeTextFile(cwd, "src/existing.ts", "export {};\n"); |
| 142 | 141 | ||
| 143 | const beforeWrite = yield* workspaceEntries.search({ | 142 | const beforeWrite = yield* workspaceEntries.list({ cwd }); |
| 144 | cwd, | 143 | expect(beforeWrite.entries.some((entry) => entry.path === "plans/effect-rpc.md")).toBe( |
| 145 | query: "rpc", | 144 | false, |
| 146 | limit: 10, | 145 | ); |
| 147 | }); | ||
| 148 | expect(beforeWrite).toEqual({ | ||
| 149 | entries: [], | ||
| 150 | truncated: false, | ||
| 151 | }); | ||
| 152 | 146 | ||
| 153 | yield* workspaceFileSystem.writeFile({ | 147 | yield* workspaceFileSystem.writeFile({ |
| 154 | cwd, | 148 | cwd, |
| @@ -156,11 +150,7 @@ it.layer(TestLayer)("WorkspaceFileSystemLive", (it) => { · 1 unmodified line | |||
| 156 | contents: "# Plan\n", | 150 | contents: "# Plan\n", |
| 157 | }); | 151 | }); |
| 158 | 152 | ||
| 159 | const afterWrite = yield* workspaceEntries.search({ | 153 | const afterWrite = yield* workspaceEntries.list({ cwd }); |
| 160 | cwd, | ||
| 161 | query: "rpc", | ||
| 162 | limit: 10, | ||
| 163 | }); | ||
| 164 | expect(afterWrite.entries).toEqual( | 154 | expect(afterWrite.entries).toEqual( |
| 165 | expect.arrayContaining([expect.objectContaining({ path: "plans/effect-rpc.md" })]), | 155 | expect.arrayContaining([expect.objectContaining({ path: "plans/effect-rpc.md" })]), |
| 166 | ); | 156 | ); |