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 { 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 firestore from "@distilled.cloud/gcp/firestore_v1"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | import { MinimumLogLevel } from "effect/References"; |
| 8 | |
| 9 | const { test } = Test.make({ providers: GCP.providers() }); |
| 10 | |
| 11 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 12 | |
| 13 | const runLifecycle = !process.env.FAST; |
| 14 | |
| 15 | test.provider( |
| 16 | "getProjectsDatabasesBackupSchedules on a missing schedule fails with NotFound", |
| 17 | (stack) => |
| 18 | Effect.gen(function* () { |
| 19 | const { project } = yield* GcpEnvironment.current; |
| 20 | |
| 21 | yield* stack.destroy(); |
| 22 | |
| 23 | const error = yield* Effect.flip( |
| 24 | firestore.getProjectsDatabasesBackupSchedules({ |
| 25 | name: `projects/${project}/databases/alchemy-missing-xxxx/backupSchedules/alchemy-missing`, |
| 26 | }), |
| 27 | ); |
| 28 | expect(error._tag).toBe("NotFound"); |
| 29 | |
| 30 | yield* stack.destroy(); |
| 31 | }).pipe(logLevel), |
| 32 | { tags: ["provider:gcp", "provider:gcp:firestore", "live"], timeout: 90_000 }, |
| 33 | ); |
| 34 | |
| 35 | test.provider.skipIf(!runLifecycle)( |
| 36 | "create, update, and delete a firestore backup schedule", |
| 37 | (stack) => |
| 38 | Effect.gen(function* () { |
| 39 | yield* stack.destroy(); |
| 40 | |
| 41 | const created = yield* stack.deploy( |
| 42 | Effect.gen(function* () { |
| 43 | const database = yield* GCP.Firestore.Database("App", { |
| 44 | location: "us-central1", |
| 45 | type: "FIRESTORE_NATIVE", |
| 46 | }); |
| 47 | const schedule = yield* GCP.Firestore.DatabasesBackupSchedule("Nightly", { |
| 48 | database: database.name, |
| 49 | retention: "604800s", |
| 50 | dailyRecurrence: true, |
| 51 | }); |
| 52 | return { database, schedule }; |
| 53 | }), |
| 54 | ); |
| 55 | |
| 56 | expect(created.schedule.name).toContain("/backupSchedules/"); |
| 57 | expect(created.schedule.databaseId).toEqual(created.database.databaseId); |
| 58 | expect(created.schedule.dailyRecurrence).toEqual(true); |
| 59 | expect(created.schedule.retention).toEqual("604800s"); |
| 60 | |
| 61 | const fetched = yield* firestore.getProjectsDatabasesBackupSchedules({ |
| 62 | name: created.schedule.name, |
| 63 | }); |
| 64 | expect(fetched.name).toEqual(created.schedule.name); |
| 65 | expect(fetched.retention).toEqual("604800s"); |
| 66 | expect(fetched.dailyRecurrence).toEqual(expect.anything()); |
| 67 | |
| 68 | const updated = yield* stack.deploy( |
| 69 | Effect.gen(function* () { |
| 70 | const database = yield* GCP.Firestore.Database("App", { |
| 71 | databaseId: created.database.databaseId, |
| 72 | location: "us-central1", |
| 73 | type: "FIRESTORE_NATIVE", |
| 74 | }); |
| 75 | const schedule = yield* GCP.Firestore.DatabasesBackupSchedule("Nightly", { |
| 76 | database: database.name, |
| 77 | retention: "1209600s", |
| 78 | dailyRecurrence: true, |
| 79 | }); |
| 80 | return { database, schedule }; |
| 81 | }), |
| 82 | ); |
| 83 | |
| 84 | expect(updated.schedule.name).toEqual(created.schedule.name); |
| 85 | expect(updated.schedule.retention).toEqual("1209600s"); |
| 86 | |
| 87 | const refetched = yield* firestore.getProjectsDatabasesBackupSchedules({ |
| 88 | name: created.schedule.name, |
| 89 | }); |
| 90 | expect(refetched.retention).toEqual("1209600s"); |
| 91 | |
| 92 | yield* stack.destroy(); |
| 93 | }).pipe(logLevel), |
| 94 | { |
| 95 | tags: ["provider:gcp", "provider:gcp:firestore", "live"], |
| 96 | timeout: 180_000, |
| 97 | }, |
| 98 | ); |