@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 90 lines 2.74 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as pubsublite from "@distilled.cloud/gcp/pubsublite_v1";
5 import * as Effect from "effect/Effect";
6 import { logLevel, currentProject, region, runLifecycle, waitUntilGone } from "./common.ts";
7
8 const { test } = Test.make({ providers: GCP.providers() });
9
10 test.provider(
11 "getAdminProjectsLocationsReservations on a missing reservation fails with a typed tag",
12 (stack) =>
13 Effect.gen(function* () {
14 const project = yield* currentProject;
15
16 yield* stack.destroy();
17
18 const error = yield* Effect.flip(
19 pubsublite.getAdminProjectsLocationsReservations({
20 name: `projects/${project}/locations/${region}/reservations/alchemy-missing-reservation`,
21 }),
22 );
23 expect(error._tag).toEqual("NotFound");
24
25 yield* stack.destroy();
26 }).pipe(logLevel),
27 {
28 tags: ["provider:gcp", "provider:gcp:pubsublite", "live"],
29 timeout: 90_000,
30 },
31 );
32
33 test.provider.skipIf(!runLifecycle)(
34 "create, update, and delete a reservation",
35 (stack) =>
36 Effect.gen(function* () {
37 yield* stack.destroy();
38
39 const created = yield* stack.deploy(
40 Effect.gen(function* () {
41 return yield* GCP.PubSubLite.AdminReservation("Capacity", {
42 location: region,
43 throughputCapacity: "4",
44 });
45 }),
46 );
47
48 expect(created.name).toContain("/reservations/");
49 expect(created.reservationId).toContain("+alc.");
50 expect(created.location).toEqual(region);
51 expect(created.throughputCapacity).toEqual("4");
52
53 const fetched = yield* pubsublite.getAdminProjectsLocationsReservations({
54 name: created.name,
55 });
56 expect(fetched.name).toEqual(created.name);
57 expect(fetched.throughputCapacity).toEqual("4");
58
59 const updated = yield* stack.deploy(
60 Effect.gen(function* () {
61 return yield* GCP.PubSubLite.AdminReservation("Capacity", {
62 reservationId: created.reservationId,
63 location: region,
64 throughputCapacity: "8",
65 });
66 }),
67 );
68
69 expect(updated.name).toEqual(created.name);
70 expect(updated.throughputCapacity).toEqual("8");
71
72 const refetched = yield* pubsublite.getAdminProjectsLocationsReservations({
73 name: created.name,
74 });
75 expect(refetched.throughputCapacity).toEqual("8");
76
77 yield* stack.destroy();
78
79 const gone = yield* waitUntilGone(
80 pubsublite.getAdminProjectsLocationsReservations({
81 name: created.name,
82 }),
83 );
84 expect(gone).toEqual("gone");
85 }).pipe(logLevel),
86 {
87 tags: ["provider:gcp", "provider:gcp:pubsublite", "live"],
88 timeout: 90_000,
89 },
90 );