@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 42 lines 1.83 KB
Raw
1 import { orderedParts } from "@alchemy.run/git/BlobStore";
2 import { describe, expect, test } from "@alchemy.run/test";
3 import { RuntimeContext } from "alchemy/RuntimeContext";
4 import * as Effect from "effect/Effect";
5 import { makeMemoryBlobStore } from "./harness/store.ts";
6
7 describe("multipart parts", { tags: ["unit", "local"] }, () => {
8 test("orderedParts sorts by part number regardless of settle order", () => {
9 // The push pipeline's hasher isolates upload parts concurrently and the
10 // small tail settles before earlier parts do.
11 const parts = [1, 3, 6, 2, 5, 4].map((partNumber) => ({
12 partNumber,
13 etag: `e${partNumber}`,
14 }));
15 expect(orderedParts(parts).map((p) => p.partNumber)).toEqual([1, 2, 3, 4, 5, 6]);
16 });
17 test("the memory store enforces R2's uniform-part rule as R2 does", async () => {
18 const blobs = makeMemoryBlobStore();
19 const result = await Effect.runPromise(
20 Effect.gen(function* () {
21 const upload = yield* blobs.multipart("k");
22 const parts = [
23 yield* blobs.uploadPart("k", upload.uploadId, 1, new Uint8Array(8)),
24 yield* blobs.uploadPart("k", upload.uploadId, 3, new Uint8Array(3)),
25 yield* blobs.uploadPart("k", upload.uploadId, 2, new Uint8Array(8)),
26 ];
27 // As given: [1, 3, 2] puts the small part in the middle → rejected.
28 const unsorted = yield* Effect.result(upload.complete(parts));
29 const sorted = yield* Effect.result(upload.complete(orderedParts(parts)));
30 const head = yield* blobs.head("k");
31 return {
32 unsorted: unsorted._tag,
33 sorted: sorted._tag,
34 size: head?.size,
35 };
36 }).pipe(Effect.provide(RuntimeContext.phantom)),
37 );
38 expect(result.unsorted).toBe("Failure");
39 expect(result.sorted).toBe("Success");
40 expect(result.size).toBe(19);
41 });
42 });