@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 49 lines 1.94 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as pubsub from "@distilled.cloud/gcp/pubsub_v1";
6 import * as storage from "@distilled.cloud/gcp/storage_v1";
7 import * as Effect from "effect/Effect";
8
9 const { test } = Test.make({ providers: GCP.providers() });
10
11 const gone = <A, E extends { readonly _tag: string }, R>(self: Effect.Effect<A, E, R>) =>
12 self.pipe(
13 Effect.as("found" as const),
14 Effect.catchIf(
15 (error) => error._tag === "NotFound",
16 () => Effect.succeed("gone" as const),
17 ),
18 );
19
20 test.provider(
21 "renaming a topic or bucket replaces it and deletes the old one",
22 (stack) =>
23 Effect.gen(function* () {
24 yield* stack.destroy();
25 const { project } = yield* GcpEnvironment.current;
26 const deploy = (suffix: string) =>
27 stack.deploy(
28 Effect.gen(function* () {
29 const topic = yield* GCP.PubSub.Topic("Renamed", {
30 topicId: `alchemy-rename-${suffix}`,
31 });
32 const bucket = yield* GCP.Storage.Bucket("RenamedBucket", {
33 bucketName: `alchemy-rename-${project}-${suffix}`,
34 forceDestroy: true,
35 });
36 return { topic: topic.name, bucket: bucket.bucketName };
37 }),
38 );
39 const first = yield* deploy("a");
40 const second = yield* deploy("b");
41 expect(second.topic).not.toEqual(first.topic);
42 expect(second.bucket).not.toEqual(first.bucket);
43 expect(yield* gone(pubsub.getProjectsTopics({ topic: first.topic }))).toEqual("gone");
44 expect(yield* gone(storage.getBuckets({ bucket: first.bucket }))).toEqual("gone");
45 expect(yield* gone(pubsub.getProjectsTopics({ topic: second.topic }))).toEqual("found");
46 yield* stack.destroy();
47 }),
48 { tags: ["provider:gcp", "provider:gcp:pubsub", "live"], timeout: 180_000 },
49 );