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
| 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 datalabeling from "@distilled.cloud/gcp/datalabeling_v1beta1"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { logLevel, probe, currentProject, runLifecycle, waitUntilGone } from "./common.ts"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: GCP.providers() }); |
| 9 | |
| 10 | test.provider( |
| 11 | "getProjectsAnnotationSpecSets on a missing set fails with a typed tag", |
| 12 | (stack) => |
| 13 | Effect.gen(function* () { |
| 14 | const project = yield* currentProject; |
| 15 | yield* stack.destroy(); |
| 16 | |
| 17 | const error = yield* Effect.flip( |
| 18 | probe( |
| 19 | datalabeling.getProjectsAnnotationSpecSets({ |
| 20 | name: `projects/${project}/annotationSpecSets/alchemy-missing-specs`, |
| 21 | }), |
| 22 | ), |
| 23 | ); |
| 24 | expect(error._tag).toEqual("NotFound"); |
| 25 | |
| 26 | yield* stack.destroy(); |
| 27 | }).pipe(logLevel), |
| 28 | { |
| 29 | tags: ["provider:gcp", "provider:gcp:datalabeling", "live"], |
| 30 | timeout: 90_000, |
| 31 | }, |
| 32 | ); |
| 33 | |
| 34 | test.provider.skipIf(!runLifecycle)( |
| 35 | "create, replace, and delete an annotation spec set", |
| 36 | (stack) => |
| 37 | Effect.gen(function* () { |
| 38 | yield* stack.destroy(); |
| 39 | |
| 40 | const created = yield* stack.deploy( |
| 41 | Effect.gen(function* () { |
| 42 | return yield* GCP.DataLabeling.AnnotationSpecSet("Classes", { |
| 43 | displayName: "pets", |
| 44 | description: "companion animals", |
| 45 | annotationSpecs: [{ displayName: "dog" }, { displayName: "cat" }], |
| 46 | }); |
| 47 | }), |
| 48 | ); |
| 49 | |
| 50 | expect(created.name).toContain("/annotationSpecSets/"); |
| 51 | expect(created.displayName).toEqual("pets"); |
| 52 | expect(created.description).toEqual("companion animals"); |
| 53 | expect(created.annotationSpecs.map((spec) => spec.displayName)).toEqual(["dog", "cat"]); |
| 54 | |
| 55 | const fetched = yield* datalabeling.getProjectsAnnotationSpecSets({ |
| 56 | name: created.name, |
| 57 | }); |
| 58 | expect(fetched.name).toEqual(created.name); |
| 59 | expect(fetched.description).toContain("alchemy-id="); |
| 60 | expect(fetched.description).toContain("companion animals"); |
| 61 | |
| 62 | const updated = yield* stack.deploy( |
| 63 | Effect.gen(function* () { |
| 64 | return yield* GCP.DataLabeling.AnnotationSpecSet("Classes", { |
| 65 | annotationSpecSetId: created.annotationSpecSetId, |
| 66 | displayName: "pets", |
| 67 | description: "updated companion animals", |
| 68 | annotationSpecs: [{ displayName: "dog" }, { displayName: "cat" }], |
| 69 | }); |
| 70 | }), |
| 71 | ); |
| 72 | |
| 73 | expect(updated.description).toEqual("updated companion animals"); |
| 74 | |
| 75 | yield* stack.destroy(); |
| 76 | const gone = yield* waitUntilGone( |
| 77 | datalabeling.getProjectsAnnotationSpecSets({ name: updated.name }), |
| 78 | ); |
| 79 | expect(gone).toEqual("gone"); |
| 80 | }).pipe(logLevel), |
| 81 | { |
| 82 | tags: ["provider:gcp", "provider:gcp:datalabeling", "live"], |
| 83 | timeout: 90_000, |
| 84 | }, |
| 85 | ); |