@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 103 lines 3.38 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, runLifecycle, waitUntilGone, zone } from "./common.ts";
7
8 const { test } = Test.make({ providers: GCP.providers() });
9
10 test.provider(
11 "getAdminProjectsLocationsTopics on a missing topic 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.getAdminProjectsLocationsTopics({
20 name: `projects/${project}/locations/${zone}/topics/alchemy-missing-topic`,
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 topic",
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.AdminTopic("Events", {
42 location: zone,
43 partitionConfig: {
44 count: 1,
45 capacity: { publishMibPerSec: 4, subscribeMibPerSec: 4 },
46 },
47 retentionConfig: { perPartitionBytes: "32212254720" },
48 });
49 }),
50 );
51
52 expect(created.name).toContain("/topics/");
53 expect(created.topicId).toContain("+alc.");
54 expect(created.location).toEqual(zone);
55 expect(created.partitionConfig?.count).toEqual("1");
56 expect(created.partitionConfig?.capacity?.publishMibPerSec).toEqual(4);
57 expect(created.partitionConfig?.capacity?.subscribeMibPerSec).toEqual(4);
58
59 const fetched = yield* pubsublite.getAdminProjectsLocationsTopics({
60 name: created.name,
61 });
62 expect(fetched.name).toEqual(created.name);
63 expect(fetched.partitionConfig?.capacity?.publishMibPerSec).toEqual(4);
64
65 const updated = yield* stack.deploy(
66 Effect.gen(function* () {
67 return yield* GCP.PubSubLite.AdminTopic("Events", {
68 topicId: created.topicId,
69 location: zone,
70 partitionConfig: {
71 count: 1,
72 capacity: { publishMibPerSec: 4, subscribeMibPerSec: 8 },
73 },
74 retentionConfig: {
75 perPartitionBytes: "32212254720",
76 period: "86400s",
77 },
78 });
79 }),
80 );
81
82 expect(updated.name).toEqual(created.name);
83 expect(updated.partitionConfig?.capacity?.subscribeMibPerSec).toEqual(8);
84 expect(updated.retentionConfig?.period).toEqual("86400s");
85
86 const refetched = yield* pubsublite.getAdminProjectsLocationsTopics({
87 name: created.name,
88 });
89 expect(refetched.partitionConfig?.capacity?.subscribeMibPerSec).toEqual(8);
90 expect(refetched.retentionConfig?.period).toEqual("86400s");
91
92 yield* stack.destroy();
93
94 const gone = yield* waitUntilGone(
95 pubsublite.getAdminProjectsLocationsTopics({ name: created.name }),
96 );
97 expect(gone).toEqual("gone");
98 }).pipe(logLevel),
99 {
100 tags: ["provider:gcp", "provider:gcp:pubsublite", "live"],
101 timeout: 90_000,
102 },
103 );