Showing the changes to apps/server/src/workspace/WorkspaceFileSystem.test.ts (1 of 2 files). Show all
Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 2 | −import { it, describe, expect } from "@effect/vitest"; | |
| 2 | +import { assert, describe, expect, it } from "@effect/vitest"; | |
| 3 | 3 | import * as Effect from "effect/Effect"; |
| 4 | 4 | import * as FileSystem from "effect/FileSystem"; |
| 5 | 5 | import * as Layer from "effect/Layer"; |
| @@ -73,6 +73,24 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i · 67 unmodified lines | ||
| 73 | 73 | }), |
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | + it.effect("bounds previews while reporting the complete file size", () => | |
| 77 | + Effect.gen(function* () { | |
| 78 | + const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem; | |
| 79 | + const cwd = yield* makeTempDir; | |
| 80 | + const contents = "a".repeat(1024 * 1024 + 5); | |
| 81 | + yield* writeTextFile(cwd, "large.txt", contents); | |
| 82 | + | |
| 83 | + const result = yield* workspaceFileSystem.readFile({ | |
| 84 | + cwd, | |
| 85 | + relativePath: "large.txt", | |
| 86 | + }); | |
| 87 | + | |
| 88 | + assert.strictEqual(result.contents.length, 1024 * 1024); | |
| 89 | + assert.strictEqual(result.byteLength, contents.length); | |
| 90 | + assert.isTrue(result.truncated); | |
| 91 | + }), | |
| 92 | + ); | |
| 93 | + | |
| 76 | 94 | it.effect("rejects reads outside the workspace root", () => |
| 77 | 95 | Effect.gen(function* () { |
| 78 | 96 | const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem; |
| @@ -185,8 +203,11 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i · 106 unmodified lines | ||
| 185 | 203 | operationPath: resolvedPath, |
| 186 | 204 | operation: "realpath-target", |
| 187 | 205 | }); |
| 188 | − expect(error.cause).toBeInstanceOf(Error); | |
| 189 | − expect((error.cause as NodeJS.ErrnoException).code).toBe("ENOENT"); | |
| 206 | + expect(error.cause).toMatchObject({ | |
| 207 | + _tag: "PlatformError", | |
| 208 | + pathOrDescriptor: resolvedPath, | |
| 209 | + reason: { _tag: "NotFound" }, | |
| 210 | + }); | |
| 190 | 211 | }), |
| 191 | 212 | ); |
| 192 | 213 | }); |