@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.14 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 cnr from "@distilled.cloud/gcp/cloudnumberregistry_v1alpha";
5 import * as Effect from "effect/Effect";
6 import {
7 location,
8 logLevel,
9 currentProject,
10 entitled,
11 runLifecycle,
12 waitUntilGone,
13 } from "./common.ts";
14
15 const { test } = Test.make({ providers: GCP.providers() });
16
17 test.provider.skipIf(!entitled)(
18 "getProjectsLocationsRegistryBooks on a missing book fails with a typed tag",
19 (stack) =>
20 Effect.gen(function* () {
21 const project = yield* currentProject;
22
23 yield* stack.destroy();
24
25 const error = yield* Effect.flip(
26 cnr.getProjectsLocationsRegistryBooks({
27 name: `projects/${project}/locations/${location}/registryBooks/alchemy-missing-book`,
28 }),
29 );
30 expect(error._tag).toEqual("NotFound");
31
32 yield* stack.destroy();
33 }).pipe(logLevel),
34 {
35 tags: ["provider:gcp", "provider:gcp:cloudnumberregistry", "live"],
36 timeout: 90_000,
37 },
38 );
39
40 test.provider.skipIf(!runLifecycle)(
41 "create, update, and delete a registry book",
42 (stack) =>
43 Effect.gen(function* () {
44 const project = yield* currentProject;
45
46 yield* stack.destroy();
47
48 const created = yield* stack.deploy(
49 Effect.gen(function* () {
50 return yield* GCP.CloudNumberRegistry.RegistryBook("Inventory", {
51 location,
52 labels: { env: "test" },
53 });
54 }),
55 );
56
57 expect(created.registryBookId).toEqual(expect.any(String));
58 expect(created.name).toEqual(
59 `projects/${project}/locations/${location}/registryBooks/${created.registryBookId}`,
60 );
61 expect(created.location).toEqual(location);
62 expect(created.labels).toMatchObject({ env: "test" });
63
64 const fetched = yield* cnr.getProjectsLocationsRegistryBooks({
65 name: created.name,
66 });
67 expect(fetched.name).toEqual(created.name);
68 expect(fetched.labels?.env).toEqual("test");
69 expect(Object.keys(fetched.labels ?? {}).some((key) => key.startsWith("alchemy-"))).toEqual(
70 true,
71 );
72
73 const updated = yield* stack.deploy(
74 Effect.gen(function* () {
75 return yield* GCP.CloudNumberRegistry.RegistryBook("Inventory", {
76 registryBookId: created.registryBookId,
77 location,
78 labels: { env: "prod", role: "ipam" },
79 });
80 }),
81 );
82
83 expect(updated.name).toEqual(created.name);
84 expect(updated.registryBookId).toEqual(created.registryBookId);
85 expect(updated.labels).toMatchObject({ env: "prod", role: "ipam" });
86
87 const refetched = yield* cnr.getProjectsLocationsRegistryBooks({
88 name: created.name,
89 });
90 expect(refetched.labels?.env).toEqual("prod");
91 expect(refetched.labels?.role).toEqual("ipam");
92
93 yield* stack.destroy();
94 const gone = yield* waitUntilGone(
95 cnr.getProjectsLocationsRegistryBooks({ name: created.name }),
96 );
97 expect(gone).toEqual("gone");
98 }).pipe(logLevel),
99 {
100 tags: ["provider:gcp", "provider:gcp:cloudnumberregistry", "live"],
101 timeout: 90_000,
102 },
103 );